-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a way to disable automouting snapshots via access to .zfs dir #3963
Comments
@jelinekr I'm surprised this hasn't come up before. Right now there's no way to disable As for how to support this I think extending the
|
I like that proposal
|
Me too, thanks for looking into this. -----Original Message----- I like that proposal
— This communication is intended only for the addressee(s), may contain confidential, privileged or proprietary information, and may be protected by US and other laws. Your acceptance of this communication constitutes your agreement to keep confidential all the confidential information contained in this communication, as well as any information derived by you from the confidential information contained in this communication. We do not waive any confidentiality by misdelivery. If you receive this communication in error, any use, dissemination, printing or copying is strictly prohibited; please destroy all electronic and paper copies and notify the sender immediately. Nothing in this email is intended to constitute (1) investment or trading advice or recommendations or any advertisement or (2) a solicitation of an investment in any jurisdiction in which such a solicitation would be unlawful. Please note that PDT Partners, LLC, including its affiliates, reserves the right to intercept, archive, monitor and review all communications to and from its network. |
What would be the expected behavior, while snapdir=disabled is set, when a user tries to mkdir .zfs and possibly populate it with data? |
Good question, I suppose it will need to fail with a reasonable errno to ensure snapdir can be safely enabled again if desired. |
@behlendorf That makes sense. Another issue is whether it makes sense to have the snapdir property controlling .zfs or .zfs/snapshot. It feels like a mistake to conflate snapdir and ctldir. Would it make more sense to have a) two separate properties, snapdir and sharedir, b) three separate properties, snapdir, sharedir, and ctldir, c) just snapdir and ctldir, since a specific need for a separate sharedir property has yet to arise other than in this context, or d) something else? Yet, I suppose the snapdir property hidden/visible has already conflated them, so it may be fine to continue that practice. However, when snapdir=hidden, both .zfs/snapshot and .zfs/shares are actually still available. With snapdir=disabled, I guess both would become unavailable for the sake of preventing the snapshot automounting, possibly making .zfs/shares "collateral damage" depending on the user's intent. Or would you want to leave .zfs/shares access in tact even when snapdir=disabled? As for errnos, currently mkdir .zfs{,/snapshot,/shares} all set the exit status to 1 and print a "File exists" error, and touch .zfs{,/snapshot,/shares} all succeed with exit status 0. Strangely, touch .zfs actually updates the timestamp (Is this a bug?), while touch .zfs/snapshot and .zfs/shares do not update the time stamps despite the 0 exit statuses. |
This issue was addressed in master by adding support for |
Sorry, could you tell how to use |
@behlendorf how does I was surprised that the snapdirs are accessible even with This could be a potential data protection/privacy issue if data that should be deleted is still accessible to applications/containers. If a ZFS filesystem is mounted into a docker container, the snapdirs are available from within the container. EDIT: The snapshots can be listed, but the content is not accessible. (At least in my case):
I assume many zfs users are not aware of that doubly-hidden but still available |
I don't think resolves this issue. This issue (#3963) should be reopened, see also #9028. |
Reopening. Thanks for revisiting this, we should provide a mechanism to at least disable the snapshot directories. |
This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions. |
This issue is still a problem. See also the corresponding FreeBSD issue. I have explained why this is a potential security problem in this thread and in that comment. I'm surprised that nothing happens for years and I got a message from that stale bot that the issue is going to be closed automatically if nobody responds. So here is my response: This is still an issue! And it's security relevant, even though some people argue it's not. |
Note that if acb33ee lands, there may be more people exposed to this potentially security related issue. |
Hi! we independently discovered this a while back and reported it privately without being aware that there is a public issue about it already anyway. The proposed approach in the private discussion was the following (slightly truncated):
If nobody else is already working on this, we'll allocate some dev time in the near future, as we'd really like to see this gap fixed! AFAIK, the above approach is still the way to go.. |
Note that there are more security implications than SUID and SGID, which I have meanwhile outlined in this thread on the FreeBSD Forum.
May I ask why not have an option that limits access to the root user, e.g. something like
I think there are several people wanting to see this fixed (and this issue has been lingering for years), so I'd really appreciate if you provided any solution to the problem. 👍 |
sure, but (most of?) the others can only be prevented by not giving access in the first place, while for setuid/setgid we have a mount option.. also, it might be fine to allow unprivileged read access to a dataset's snapshots (e.g., an OSTree or similar contents) but we still want to prevent privilege escalation via known-vulnerable, fixed-in-the-meantime setuid/setgid binaries ;)
might also work, but I'd have to check whether that makes sense with the way the ctl dir and automounting is currently implemented. might also be possible as a follow up. |
This argument (edit: without the "most of" restriction) is often brought up, but isn't true in my opinion (as I argued in the linked discussion thread(s)). In short: There are scenarios when you execute a command like For these reasons, I consider the world-readable automounting of snapshots to be a security flaw. And this is not just related to SUID/SGID flags. However, some people have a different opinion on that. That said, I still think it's a good idea to remove SUID/SGID in the snapshots by default because it may prevent some potential security problems. 👍
Agreed.
As said, this only helps against certain mistakes/errors. But still, I think it's a good idea, just one should be aware this doesn't cover everything (in particular if you assume that snapshots have been taken at a potentially insecure state).
This is just a " Due to security reasons, I would personally advocate that the default behavior should be to have snapshots not world-readable by default (whether restricted to root or having them disabled completely by default). There may be other opinions though for backward compatibility reasons. But I believe security should have precedence here. |
I think we are pretty much on the same page :) when I wrote "not giving access in the first place" I was referring to the snapshot, not the original data. I fully agree that disabling automounting/automounted snapshot access in general (or for non-root) makes sense in a lot of setups! |
Oh okay, sorry for the misunderstanding. |
in some environments, just making the .zfs control dir hidden from sight might not be enough. in particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. the new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. Fixes: openzfs#3963 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
in some environments, just making the .zfs control dir hidden from sight might not be enough. in particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. the new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. Fixes: openzfs#3963 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
in some environments, just making the .zfs control dir hidden from sight might not be enough. in particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. the new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. I think that technically the zfs_dirlook change is enough to prevent access, but preventing lookups and dir entries in an already opened .zfs handle might also be a good idea to prevent races when modifying the property at runtime. Fixes: openzfs#3963 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> .zfs: don't return .zfs inode if disabled Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
in some environments, just making the .zfs control dir hidden from sight might not be enough. in particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. the new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. I think that technically the zfs_dirlook change is enough to prevent access, but preventing lookups and dir entries in an already opened .zfs handle might also be a good idea to prevent races when modifying the property at runtime. Fixes: openzfs#3963 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> .zfs: don't return .zfs inode if disabled Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
In some environments, just making the .zfs control dir hidden from sight might not be enough. In particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents Introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. The new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. I think that technically the zfs_dirlook change is enough to prevent access, but preventing lookups and dir entries in an already opened .zfs handle might also be a good idea to prevent races when modifying the property at runtime. Add zfs_snapshot_no_setuid parameter to control wheter automatically mounted snapshots have the setuid mount option set or not. this could be considered a partial fix for one of the scenarios mentioned in desired. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Fixes: openzfs#3963
In some environments, just making the .zfs control dir hidden from sight might not be enough. In particular, the following scenarios might warrant not allowing access at all: - old snapshots with wrong permissions/ownership - old snapshots with exploitable setuid/setgid binaries - old snapshots with sensitive contents Introducing a new 'disabled' value that not only hides the control dir, but prevents access to its contents by returning ENOENT solves all of the above. The new property value takes advantage of 'iuv' semantics ("ignore unknown value") to automatically fall back to the old default value when a pool is accessed by an older version of ZFS that doesn't yet know about 'disabled' semantics. I think that technically the zfs_dirlook change is enough to prevent access, but preventing lookups and dir entries in an already opened .zfs handle might also be a good idea to prevent races when modifying the property at runtime. Add zfs_snapshot_no_setuid parameter to control wheter automatically mounted snapshots have the setuid mount option set or not. this could be considered a partial fix for one of the scenarios mentioned in desired. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Fixes: openzfs#3963
Hi,
is there is a way to disable automouting snapshots when being accessed via .zfs directory? We need this for security reasons in cases where a too permissive dirent entry gets fixed, the vulnerability is still present and accessible in older snapshots. The "snapdir" zfs property only allows hiding the directory from readdir(3), but it doesn't prevent automounting snapshots when it's accessed. Can we add something similar to zfs_expire_snapshot variable (i.e. zfs_disable_snapshot_automount or zfs_snapshot_canmount) for this?
Thanks,
Rob
The text was updated successfully, but these errors were encountered: