Skip to content

fix(paths): reject symlinks that resolve outside the search path - #605

Closed
samuelbraun15 wants to merge 2 commits into
remsky:masterfrom
samuelbraun15:fix/resolve-within-symlink
Closed

samuelbraun15 wants to merge 2 commits into
remsky:masterfrom
samuelbraun15:fix/resolve-within-symlink

Conversation

@samuelbraun15

@samuelbraun15 samuelbraun15 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

_resolve_within evaluated 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 while os.path.realpath subsequently resolved to the outside target.

What changed

Resolved symlinks via os.path.realpath on the candidate path first, and enforced the startswith(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_root and added test_resolve_within_rejects_symlink_pointing_outside in api/tests/test_paths.py verifying that symlinks pointing outside the search root are rejected (with a graceful skip on Windows hosts without symlink privileges).

@remsky

remsky commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thanks! Closing though as following symlinks in the search roots is intentional for NAS/K8s mounts re: 9dac665

@remsky remsky closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants