lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025-11-20-limber-salted-luncheon-scads-7AT044@cyphar.com>
Date: Thu, 20 Nov 2025 13:18:34 +1100
From: Aleksa Sarai <cyphar@...har.com>
To: Alyssa Ross <hi@...ssa.is>
Cc: linux-fsdevel@...r.kernel.org, 
	Demi Marie Obenour <demiobenour@...il.com>, Jann Horn <jannh@...gle.com>, 
	"Eric W. Biederman" <ebiederm@...ssion.com>, jlayton@...nel.org, Bruce Fields <bfields@...ldses.org>, 
	Al Viro <viro@...iv.linux.org.uk>, Arnd Bergmann <arnd@...db.de>, shuah@...nel.org, 
	David Howells <dhowells@...hat.com>, Andy Lutomirski <luto@...nel.org>, 
	Christian Brauner <brauner@...nel.org>, Tycho Andersen <tycho@...ho.pizza>, linux-kernel@...r.kernel.org, 
	linux-api@...r.kernel.org
Subject: Re: Safety of resolving untrusted paths with detached mount dirfd

On 2025-11-19, Alyssa Ross <hi@...ssa.is> wrote:
> Hello,
> 
> As we know, it's not safe to use chroot() for resolving untrusted paths
> within some root, as a subdirectory could be moved outside of the
> process root while walking the path[1].  On the other hand,
> LOOKUP_BENEATH is supposed to be robust against this, and going by [2],
> it sounds like resolving with the mount namespace root as dirfd should
> also be.
> 
> My question is: would resolving an untrusted path against a detached
> mount root dirfd opened with OPEN_TREE_CLONE (not necessarily a
> filesystem root) also be expected to be robust against traversal issues?
> i.e. can I rely on an untrusted path never resolving to a path that
> isn't under the mount root?

No, if you hit an absolute symlink or use an absolute path it will
resolve to your current->fs->root (mount namespace root or chroot).
However, OPEN_TREE_CLONE will stop ".." from naively stepping out of the
detached bind-mount. If you are dealing with procfs then magic-links can
also jump out.

You can always use RESOLVE_BENEATH or RESOLVE_IN_ROOT in combination
with OPEN_TREE_CLONE.

-- 
Aleksa Sarai
https://www.cyphar.com/

Download attachment "signature.asc" of type "application/pgp-signature" (266 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ