I use ZFS snapshots and mirroring (both on a harddrive that is permanently connected and on harddrives that aren't always connected) as a means of keeping backups of my data.
Using the snapshots, I can go back in time if I accidentally delete files or something else happened to my data on the logical level. I really like that feature of ZFS.
However, keeping ZFS snapshots around for a long time seems to be a security issue – at least under certain circumstances – because snapshots of a mounted file system are always automounted and unprivileged users always have access to those snapshots (see PR 265625). That means whenever you change privileges, e.g. forbid a certain user to access some data, then these changes are effectively ignored because that user can still see the (old) data in the snapshots. The same problem arises when you, for example, remove some group's privileges to access a directory and then add a new user being member of that group whose privileges had been removed for that directory: the newly created user could read data that they weren't supposed to be able to read. So the user can access a directory even though the privileges for that directory were removed before that user has even been created and/or added to that group.
I originally brought this issue up on the FreeBSD mailinglist many years ago, but there doesn't seem to be a solution to that problem yet. It seems this issue is known already for over 8 years (see OpenZFS issue #3963).
Since this is a potential security issue, I think this needs to be fixed (or users should at least be discouraged from using this feature without knowing about the security holes it can cause). As of my current knowledge, there has been no security advisory on that problem yet.
Note that the directory can be hidden, see
What can I do in the meantime to deal with this? In some instances I ignore the security problem and just hope I won't run into any real trouble. Other times, I try to do a nullfs mount by adding something like this to my
Is this safe? Are there better ways to get rid of the
Using the snapshots, I can go back in time if I accidentally delete files or something else happened to my data on the logical level. I really like that feature of ZFS.
However, keeping ZFS snapshots around for a long time seems to be a security issue – at least under certain circumstances – because snapshots of a mounted file system are always automounted and unprivileged users always have access to those snapshots (see PR 265625). That means whenever you change privileges, e.g. forbid a certain user to access some data, then these changes are effectively ignored because that user can still see the (old) data in the snapshots. The same problem arises when you, for example, remove some group's privileges to access a directory and then add a new user being member of that group whose privileges had been removed for that directory: the newly created user could read data that they weren't supposed to be able to read. So the user can access a directory even though the privileges for that directory were removed before that user has even been created and/or added to that group.
I originally brought this issue up on the FreeBSD mailinglist many years ago, but there doesn't seem to be a solution to that problem yet. It seems this issue is known already for over 8 years (see OpenZFS issue #3963).
Since this is a potential security issue, I think this needs to be fixed (or users should at least be discouraged from using this feature without knowing about the security holes it can cause). As of my current knowledge, there has been no security advisory on that problem yet.
Note that the directory can be hidden, see
snapdir=hidden
in zfsprops(7), but users may still access it.What can I do in the meantime to deal with this? In some instances I ignore the security problem and just hope I won't run into any real trouble. Other times, I try to do a nullfs mount by adding something like this to my
/etc/fstab
:
Code:
# Device Mountpoint FStype Options Dump Pass#
/var/empty /home/.zfs/snapshot nullfs ro 0 2
Is this safe? Are there better ways to get rid of the
.zfs/snapshot
directory? I wonder what's the best practice. Do you think using snapshots for the purpose of backups is a misuse? I just don't see any other mechanism that's as handy as that to go back in time whenever you need to.