Repository navigation
fix(paths): reject symlinks that resolve outside the search path - #605
Closed
samuelbraun15 wants to merge 2 commits into
Closed
samuelbraun15 wants to merge 2 commits into
samuelbraun15 wants to merge 2 commits into
Conversation
Owner
|
Thanks! Closing though as following symlinks in the search roots is intentional for NAS/K8s mounts re: 9dac665 |
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.
What was wrong
_resolve_withinevaluated whether the candidate path string begins with the search root prefix before resolving symbolic links. If a symlink within a search root points to an external path, the string prefix check passed whileos.path.realpathsubsequently resolved to the outside target.What changed
Resolved symlinks via
os.path.realpathon the candidate path first, and enforced thestartswith(prefix)constraint on that fully resolved path. External symlinks pointing outside the search root are no longer loaded.How it's tested
Updated
test_find_file_rejects_symlinked_files_outside_rootand addedtest_resolve_within_rejects_symlink_pointing_outsideinapi/tests/test_paths.pyverifying that symlinks pointing outside the search root are rejected (with a graceful skip on Windows hosts without symlink privileges).