The whole point is that if malware gets root access (or anything that can manipulate the disk at will), there's nothing that can be done.
EDIT: briefly searched, and indeed, my suspicions were correct: https://redcanary.com/blog/its-all-fun-and-games-until-ranso....
¹=https://docs.microsoft.com/en-us/windows-server/storage/file...
Strictly true, in that if it does get root access, and is aware of zfs snapshots and deletes them, then yes. Nothing you can do.
More typically, the malware runs as the user id and has no awareness of zfs, so it just overwrites files the user owns. Which can be trivially undone with snapshots.
As with everything related to security there is no absolute, but every layer helps.
Even if the backup system isn't hacked, you can hack the original system in such a way that the pulled snapshots look like they work, but in fact did not work (ex: hack the rsync data requests to be encrypted with the ransomware key).
You gotta stop them from having root access to begin with. Hard in this day of zero-days, but a lot of these ransomware attacks don't seem very hard to pull off these days...
Also, OpenZFS can export ZVOLs over iSCSI so you can have formatted block storage for other devices that can be rolled back by snapshot on the OpenZFS.
In a virtualized environment all of the VMs' storage could be protected with snapshots.
1) Unless it's a targeted attack it's highly unlikely that a ransomware strain will be designed to target a specific filesystem. Snapshot deletion requires filesystem specific APIs, whereas reading/writing files is just standard libc fare. You would need to maintain different strains of a virus to target an organization running Btrfs vs ZFS vs ReFS, for example. - If the attacker has deep knowledge of your storage stack, and has gained privileged access to it, you've already lost: go to step 4.
2) Separation of privileges. Deleting a snapshot is a privileged command. A ransomware infection that doesn't successfully elevate privileges might be able to encrypt my home directory, which would suck, but it wouldn't have permissions to delete snapshots of my home directory.
3) Virtualization / network storage: snapshots are transparent to virtual guests, a virus inside a guest can't delete snapshots if it's not aware they exist. With network shares and ZFS: you can choose whether or not you want to expose snapshots. If you do expose them: don't grant network clients privileges to delete them.
4) Replication: with any ransomware infection the only real defense is off-site backups. Snapshots makes backups trivial. You can incrementally replicate and restore from them easily (e.g: zfs send/recv.) This alone makes using a CoW filesystem worthwhile in the defense against ransomware. Ransomware will have a hard time deleting snapshots on an air-gapped disk.
If you keep your backups on a third party cloud storage provider that runs on ZFS then those snapshots are taken by their root, not yours.
You send your backups to this cloud storage provider and they take the snapshots on your behalf.
You have an unprivileged login and have the ability to read the snapshots, but not destroy them.
In this scenario, Mallory can destroy your data and gain access to all of your cloud credentials and destroy the primary dataset ... but cannot destroy the snapshots.
I'm sure there must be some cloud provider, somewhere that offers this ... right ?
ZFS, btrfs, even LVM does snapshots, and it seems silly to use anything else for critical data/configuration.