Core: resolve policy::resolve paths component by component to close symlink dotdot bypasses #2528
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:23:39Z.
Problem
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.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:33:09Z.
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
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:23Z.
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).[PR #2530] Core: re-canonicalize policy::resolve paths after collapsing .. to close symlink bypassto [PR #2530] Core: resolve policy::resolve paths component by component to close symlink dotdot bypassesImported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T05:44:20Z.
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