Core: resolve policy::resolve paths component by component to close symlink dotdot bypasses #2530
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2530
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2530"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@reeledMarek on GitHub · 2026-11-25 15:23 UTC · original
reeledMarek:fix/core-policy-symlink-dotdot→main· +77 −27 · 1 files · 1 commits · closed without mergingProblem
victory_core::policy::resolvecanonicalized the longest existing prefix, appended the non-existing tail, and ran lexicalnormalize(&out)without re-canonicalizing the result.For a path such as
<outside>/missing/../../<link>/outwhere<link>is a symlink into a subdirectory of a repository containing.victory-root,resolvestopped at<outside>, collapsed..lexically to<parent>/<link>/out, and never resolved<link>.ensure_outside_repothen returnedOk(()), allowing downstreamcreate_dir_allto write inside the repository.Fix
canonicalize_prefixreturning(normalized_path, had_parent)...components were collapsed in the non-existing tail, run one secondcanonicalize_prefixpass on the normalized path so any exposed symlinks are resolved.Testing
rejects_symlink_into_repo_exposed_after_dotdot_collapseincrates/victory-core/src/policy.rs.cargo test -p victory-core --locked,cargo clippy -p victory-core --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, andcargo test -p xtask --locked.@Marvisak on GitHub · 2026-11-25 18:33 UTC · original · edited 2026-11-25 20:22 UTC
Automated triage for the maintainers.
Needs work. The new head rewrites
resolveincrates/victory-core/src/policy.rsto walk components and canonicalize each existing prefix before applying.., and dropsnormalize. On POSIX semantics this does close the<link>/../xcase from the last review. On Windows, the only platform VIctory builds for and the only one CI runs, it still fixes nothing, and the new Case 2 assertion describes the wrong target:..as text before it resolves anything. Socreate_dir_all("<outside>\\missing\\..\\..\\link-sub\\..\\out")creates<tmp>\\out, not<repo>\\out. The test's comment ("steps out of<repo>/subinto<repo>/out") does not hold there. The new code now rejects a path that Windows would write outside the repository. That is stricter, so it is harmless, but the test asserts behaviour Windows does not have. Case 1 was already refused onmain, becausecanonicalizesucceeds on the whole prefix.\\?\\verbatim-path test case, but the diff has none. It contains onlyrejects_symlink_into_repo_across_dotdot_components, which builds ordinary paths withjoin.What would change the verdict: a test that fails on
mainin the Windows CI (for example the verbatim-path case you describe, if..in such a path really reaches the filesystem), or a maintainer decision that POSIX semantics matter for this crate. In either case, Case 2's comment should say which platform it applies to.Reply to the author: thanks for the rewrite. Point 2 is addressed for POSIX paths. Point 1, a failing case on Windows, is still open, because the verbatim-path test the reply mentions is not in the pushed commit (
a10368d).CI:
checkpassed (Windows).Generated by Claude Code
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
Updated to address both triage points:
policy::resolveto walk path components left-to-right, canonicalizing each existing prefix before applying... This fixes<outside>/missing/../../<link>/../out(where<link> -> <repo>/sub) in addition to<outside>/missing/../../<link>/out.\\?\verbatim-path test case where Win32 does not collapse..lexically before passing paths to the kernel (in addition to Linux/cross-platform CLI builds).@reeledMarek on GitHub · 2026-11-26 05:44 UTC · original
Closing per triage: Win32 normalizes
..lexically before resolving symlinks (and\?\verbatim paths do not interpret..as parent traversal), while Case 1 is already rejected onmain. Since VIctory targets x86-64 Windows only, this change only affects POSIX semantics and isn't worth the extra complexity. Thanks for the careful Windows analysis!Pull request closed