Repository navigation
cf-serverd: Fixed path ACL bypass through dangling symlink requests - #6509
Open
Dhanu-dynamic wants to merge 1 commit into
Open
Dhanu-dynamic wants to merge 1 commit into
Dhanu-dynamic wants to merge 1 commit into
Conversation
PreprocessRequestPath() (TLS protocol) and AccessControl() (classic protocol) canonicalise the requested path with realpath() before matching it against the path ACL, and that match is a plain string prefix check. realpath() fails on a dangling symlink, and both functions then fell back to the path exactly as the client sent it, with '..' components and symlinked directories unresolved. A client admitted to /srv/admitted could request /srv/admitted/../../etc/some-dangling-link: lstat() resolves it outside the admitted tree, while the prefix match admits it (and deny rules miss it). STAT then returns the lstat() metadata and readlink() target of any dangling symlink on the server. For a dangling symlink, canonicalise its parent directory with realpath() and append the link name instead. The classic branch also no longer reads statbuf after a failed lstat(). Changelog: Title Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PreprocessRequestPath() (TLS protocol) and AccessControl() (classic protocol) canonicalise the requested path with realpath() before matching it against the path ACL, and that match is a plain string prefix check. realpath() fails on a dangling symlink, and both functions then fell back to the path exactly as the client sent it, with
..components and symlinked directories unresolved. A client admitted to/srv/admittedcould request/srv/admitted/../../etc/some-dangling-link: lstat() resolves it outside the admitted tree, while the prefix match admits it (and deny rules miss it). STAT then returns the lstat() metadata and readlink() target of any dangling symlink on the server.For a dangling symlink, canonicalise its parent directory with realpath() and append the link name instead. The classic branch also no longer reads
statbufafter a failed lstat().The new
test_preprocess_request_path_dangling_symlinkintests/unit/protocol_test.crequests<tmp>/admitted/../danglingand expects<tmp>/dangling; before the change the raw path comes back. I checked the helper with a standalone harness (old fallback admits the..path under a/srv/admittedprefix rule, new one yields/etc/danglingand is refused), but have not run the full autotools build and unit suite on Linux yet; CI will confirm.