xcl run: confine manifest/config exe paths to game root and preserve CreateProcessW error #1586
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1586
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@b3IKK on GitHub · 2026-11-24 17:59 UTC · original
b3IKK:launcher/path-containment-and-lasterror→main· +73 −5 · 1 files · 1 commits · openFixes 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.In launcher.rs: - pick_exe() and run() joined MicrosoftGame.config `<Executable Name=...>` and `xcl.toml` `exe` directly onto `root` via `Path::join`. In Rust, `Path::join` replaces `root` for absolute/drive-rooted paths and allows `..` parent traversal, letting a manifest or config escape the game folder and execute an arbitrary `.exe`. - spawn_host() called `std::env::remove_var("XCL_HOST")` before reading `GetLastError()`, which can overwrite the thread's Win32 error code before reporting why `CreateProcessW` failed. Add exe_inside_root() to reject absolute/parent components and verify canonical containment inside `root`, and capture `GetLastError()` immediately after `CreateProcessW` before `remove_var`. Assisted-by: OpenCode (Gemini 4 Neon)@pickles976 on GitHub · 2026-11-24 18:03 UTC · original
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.@b3IKK on GitHub · 2026-11-24 18:47 UTC · original
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.@futurepro62 on GitHub · 2026-11-24 18:55 UTC · original
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
@DavidM1911 on GitHub · 2026-11-24 20:02 UTC · original
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!
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
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.