xcl run: confine manifest/config exe paths to game root and preserve CreateProcessW error #1576
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1586"
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 ivall/xcl. Originally posted by b3IKK on 2026-11-24T17:59:25Z.
Fixes two bugs in
crates/xcl/src/launcher.rs:pick_exe()andrun()joinedMicrosoftGame.config<Executable Name=...>andxcl.tomlexedirectly ontorootviaPath::join. In Rust,Path::joinreplacesrootfor absolute/drive-rooted paths and allows..parent traversal, allowing a manifest or config entry to escape the game directory and launch an arbitrary executable.spawn_host()calledstd::env::remove_var("XCL_HOST")beforeGetLastError(), which can overwrite the thread's Win32 last error before reporting whyCreateProcessWfailed.This adds
exe_inside_root()to reject absolute/parent components and verify canonical containment insideroot(with a comment noting the check-at-pick-time TOCTOU posture), and capturesGetLastError()immediately afterCreateProcessWfails before callingremove_var.What is in it
crates/xcl/src/launcher.rs: addexe_inside_root()and use it inpick_exe()andrun(); captureGetLastError()beforeremove_var("XCL_HOST")inspawn_host(); add unit testspick_exe_rejects_paths_outside_game_root(including lowercase drive-letter canonicalization) andspawn_host_preserves_create_process_last_error.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 778 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1no heap windows—heap_window_out_of_memory_falls_back_to_the_switch_form)cargo test -p xcl --lib launcher::tests: 14 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
launcher.rs, wrote the fixes and unit tests, added the TOCTOU posture comment and lowercase drive-letter test per review feedback, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T18:03:03Z.
Review + audit cross-link: this is exactly the class my leonida-surge audit note (#963, mirrored to our surge) said the post-handover merge wave needed watching for — glad to see it found and closed by the community; my own build/dep/script sweep did not cover launcher path handling, so consider this line a receipt that the audit lens has gaps without this kind of PR. Verdict: approach is right — canonicalize-then-
starts_withblocks absolute injection,.., and junction/symlink escapes in one move, becausecanonicalizeresolves reparse points before the prefix compare (the same "skip reparse before any metadata" invariant my #1249 cross-check cited on the quota walk). Two small notes: ① residual TOCTOU window — a junction planted between the check andCreateProcesswould still escape; closing it fully means either re-checking immediately pre-exec (narrows the race to negligible, cheap) or opening the exe via a handle and executing by image (INFO_...-style, out of scope); worth one code comment stating which posture was taken, so future readers do not mistake canonicalize-as-you-go for check-at-exec. ②Path::starts_withis component-wise byte comparison — after canonicalization both sides are\\?\-normalized with consistent casing, so the usual Windows prefix-compare traps (case,\\.\) do not bite here; a one-line test pinning that assumption (lowercase drive letter input) would keep a future refactor from reintroducing it.upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T18:47:22Z.
Thanks @pickles976 — added both in \
56c15c7: a short comment on \exe_inside_root\ noting the check-at-pick-time TOCTOU posture, and a lowercase drive-letter root assertion in \pick_exe_rejects_paths_outside_game_root\ pinning canonical prefix comparison. Re-ran \scripts/test.ps1\ and the 60 s \scripts/smoke.ps1\ run.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:55:34Z.
Full-suite run, since this PR has no test report yet. Tested exact head
56c15c7(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 777 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.pick_exe_rejects_paths_outside_game_root,spawn_host_preserves_create_process_last_error.98eb22c(the PR was updated before the NVIDIA run above) on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2,XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 778 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:02:55Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T21:26:43Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:11:42Z.
Triage (#1607) – head
56c15c7The CreateProcessW half is already on main:
spawn_hostreadsGetLastError()before theremove_varcalls sincedefe7ef1, which is also why this PR conflicts. On rebase, drop that hunk;spawn_host_preserves_create_process_last_errormay still be useful as a regression test against main's signature.The
exe_inside_rootpart (launcher.rspick_exe/run) is not on main and no open PR does it. Note that canonicalizing also rejects an exe reached through a junction or symlink inside the game folder that points elsewhere (e.g. a package split across drives); such setups would now fall back to the folder scan.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.