xcl run: keep credentials out of the game process environment (#702) #730
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!730
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-730"
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?
@Luxuryig on GitHub · 2026-11-24 04:14 UTC · original
Luxuryig:host-env-without-credentials→main· +135 −2 · 2 files · 1 commits · openThe game runs in a child of
xcl.CreateProcessWwas passed no environment block, so the child inherited the whole user environment. A crash dump of that process then contains those variables, including credentials set as user variables. The child now gets a Unicode block withSystemRoot,windir,SystemDrive,TEMP,TMP,LOCALAPPDATA,XCL_*, machine Program Files paths, and aPATHof only%SystemRoot%\System32.LOCALAPPDATAstays because the data folder and the DXIL cache use it; that path still contains the Windows account name.XCL_KEEP_ENV=1passes the environment through unchanged.Fixes #702
What is in it
crates/xcl/src/launcher.rs:build_host_env_blockfilters the block passed toCreateProcessW, and a unit test checks that a secret and the user profile are absent whileXCL_*andSystemRootremainREADME.md: the run section says what the game process inherits and namesXCL_KEEP_ENVTested
.\scripts\test.ps1(debug) on this commit: exit 0. 693 passed, 0 failed, 41 ignoredgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)XCL_SAMPLE_RPF,XCL_SAMPLE_DLLS,XCL_SAMPLE_TTPF,XCL_SAMPLE_BK2,XCL_SAMPLE_BVH4,XCL_SAMPLE_AWC,XCL_SAMPLE_XG,XCL_SAMPLE_DXCe2e::test_title_runs_and_game_folder_is_untouchedpassed inside that suite, so the filtered child still runs the in-tree titleAtomic::fetch_updateincrates/xcl/src/hle/xgameruntime/mod.rs:547(not touched)Regression run
Both runs host the in-tree test title (
xcl-smoke-game) for 20 seconds with--hello, because that title exits 1 without it andscripts/smoke.ps1counts a non-zero exit as a crash.scripts/smoke.ps1has no parameter for title arguments; a local edit supplied--helloand is not in this commit. A freshXCL_DATA_ROOTwas used for each run. The PR run exited at 1.985 s, before the 2 s activity line, so its peak isn/a. Main exited at 2.149 s and logged one.main (
63cdc25):this PR (
e494814):Not tested
CreateProcessWreceives; the smoke runs are a host regression only.XCL_KEEP_ENV=1was not used for the smoke runsAI use
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@emirduran707 on GitHub · 2026-11-24 04:18 UTC · original
AMD test report for
e494814(this PR's head).Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4: 693 passed, 0 failed, 41 ignored; noSKIPPEDlines.scripts/smoke.ps1on the retail title, 60 s, no input:mainf4ce27con the same machine and title: 1578 frames, peak commit 14765 MB, no device removal, no crash.xcl runwith a canary variable (CANARY_SECRET_TOKEN) set in the calling shell, and read the environment block of each process from its PEB 12 s in.xcl.exe, which runs the title, had 24:ALLUSERSPROFILE,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,LOCALAPPDATA,NUMBER_OF_PROCESSORS,OS,PATH,PATHEXT, the fourPROCESSOR_*,ProgramData,ProgramFiles,ProgramFiles(x86),ProgramW6432,SystemDrive,SystemRoot,TEMP,TMP,windir,XCL_RUN_SECONDSandXCL_UMA_MB. No canary, no user or computer name.Not tested
Two notes from reading the diff, neither a blocker:
std::env::vars()panics if a variable is not valid Unicode (on Windows, an unpaired surrogate), so the launcher would stop there.vars_os()with lossy conversion of the kept names avoids that.WINE*,VKD3D_*andDXVK_*are not kept, so a user's vkd3d-proton / DXVK settings would no longer reach the host process.Tested and written with Claude Code (Claude Opus 5.5). The runs were made on my machine.
@MesshM on GitHub · 2026-11-24 04:21 UTC · original
Test run of
e494814d7ff60439114c5a2e75543b5285cc1595on AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED;game_process_environment_drops_credentials_and_the_user_profilepasses.Review: Passing an allow-list instead of the whole user environment is a good idea for crash dumps, and
XCL_KEEP_ENV=1restores the old behaviour. A question rather than a finding: the list leaves outUSERPROFILE,APPDATA,ProgramData,ComSpec,NUMBER_OF_PROCESSORSandPROCESSOR_ARCHITECTURE. The known-folder APIs do not need them, but some DLLs a title or the system runtime loads read them straight from the environment (%ProgramData%for shared caches,NUMBER_OF_PROCESSORSin some thread-pool sizing). I could not run a title to see whether anything misses them; a retail run with and withoutXCL_KEEP_ENV=1would tell. DXC is not affected, since it is found through the SDK paths andXCL_DXC_DIR, notPATH.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@RandomGithub12309 on GitHub · 2026-11-24 04:39 UTC · original
Independent NVIDIA test report and review of
e494814d7ff60439114c5a2e75543b5285cc1595(on base63cdc25):Tested
32.0.16.2114, wave32, SM 6.6), Intel Core Ultra 7 255HX (20 cores), Windows 11 Build 26300,rustc 1.100.0stable-x86_64-pc-windows-msvc, debug buildcargo build --workspace+cargo test --workspace -- --test-threads=4launcher::tests::game_process_environment_drops_credentials_and_the_user_profilepasses)SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Review
keep_env_name(crates/xcl/src/launcher.rs):name.len() >= 4 && name[..4].eq_ignore_ascii_case("XCL_")slices&strat byte offset4, which panics if any host environment variable name has a multi-byte UTF-8 character spanning byte4.name.as_bytes().get(..4).is_some_and(|b| b.eq_ignore_ascii_case(b"XCL_"))avoids this.CREATE_UNICODE_ENVIRONMENTblock:build_host_env_blockpushes kept entries instd::env::vars()iteration order and appendsPATHat the end afterXCL_*instead of sorting case-insensitively by variable name as expected by WindowsCreateProcessW.Not tested
xcl run) /XCL_KEEP_ENV=1AI use
e494814, audited the diff, ran the workspace suite, and wrote this report.@upipibi on GitHub · 2026-11-24 05:07 UTC · original
One small point on
e494814, from reading the code:build_host_env_blockkeeps the input order and then appendsPATHlast (launcher.rs,out.push(("PATH", …))after the loop), so the block ends… windir=…, XCL_…=…, PATH=…, not in sorted order. Windows documents that the strings in an environment block passed toCreateProcessWmust be sorted alphabetically by name, case-insensitively ("Changing Environment Variables" on Microsoft Learn). Lookups usually still work, but code in the child that edits the environment assumes that order. Sortingoutbyk.to_uppercase()before building the block would follow it; #766 sorts its block the same way.AI-assisted (Claude Code), read-only review.
@throny on GitHub · 2026-11-24 19:38 UTC · original
Two contributors checked independently and found that #740 #766 solves the same problem (for #702) in a different way: #1607, group D17. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@DavidM1911 on GitHub · 2026-11-25 11:38 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.