VFS: audit case-insensitive path canonicalization, whiteouts, and traversal boundaries #1560
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!1560
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1560"
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?
@slopgobblercobbler on GitHub · 2026-11-24 17:40 UTC · original
slopgobblercobbler:fix/vfs-path-canonicalization-bounds→main· +392 −86 · 1 files · 1 commits · openSummary
Audits virtual file system (VFS) path canonicalization, whiteouts case-insensitivity, and traversal bounds in
crates/xcl/src/vfs.rs:strip_verbatim: made verbatim UNC prefix checks case-insensitive (\\?\unc\,\\?\Unc\,\\?\UNC\) and supported NT object manager namespace prefixes (\??\unc\,\??\), preventing lowercase verbatim UNC paths from being stripped tounc\...and incorrectly treated as local relative paths.Vfs::new: normalizedgame_root,data_root, and mount targets withfull_path,strip_verbatim, andnorm, and normalized mount prefixes withnormandto_ascii_lowercase(so mount definitions containing forward slashes cleanly match normalized paths).classify_with: fixed character slice calculations when stripping the game root prefix to prevent boundary panics on mixed-case or unicode paths, and verified relative remainders usingclean_rel.clean_rel(rel: &str) -> Option<String>which normalizes slashes, trims redundant separators, and resolves.and..segments.wkey: maps relative paths to canonical lowercase keys viaclean_rel, ensuring whiteout operations (is_whiteout,has_whiteouts_under,add_whiteout,remove_whiteout) are completely case- and slash-invariant (data\gone.txt,DATA\GONE.TXT,data/gone.txt,data/./gone.txt,\data\gone.txt\).has_whiteouts_underandneeds_mergewhen queried with trailing or forward slashes (data\,data/,DATA), preventingdata\\\\prefix mismatch bugs.Vfs::new: canonicalized existing.xcl_whiteoutsentries throughSelf::wkeyupon loading.clean_rel: added strict boundary checks that reject paths attempting to traverse above the root via..(when the component stack is empty) or containing drive letters, UNC, or device streams, returningNone.Vfsmethods (delete_file,stage_write,prepare_write,create_dir,remove_dir,open_decision_for,read_path_rel,visible_in_overlay,visible_in_original,exists,is_dir): enforced boundary validation viaclean_rel, rejecting traversal escapes with safe Win32 error codes (ERROR_PATH_NOT_FOUND/ERROR_FILE_NOT_FOUND) without filesystem access.clean_rel_resolves_dots_and_detects_boundary_traversal,case_insensitive_whiteouts_across_slashes_and_dots,strip_verbatim_supports_mixed_case_unc_and_nt_prefixes,remove_dir_enforces_clean_rel_and_bounds.Changes
crates/xcl/src/vfs.rs:clean_relhelper for robust segment resolution and traversal escape defense.strip_verbatim.wkeyand.xcl_whiteoutsloader.Tested
cargo test -p xcl -- vfs: 22 passed, 0 failed.upstream/main, GPL-2.0-only compliant, zero retail game data or keys.Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
@Anon64 on GitHub · 2026-11-24 17:54 UTC · original
Regression run for this PR: head
6caef61, based onmain9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s.main
9e3831e:this PR:
No device removals or crashes; 85 % of main's frames, 113 % of its peak commit.
Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies a lot from run to run (21–92 GB with the same build), so it says little about this PR.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@futurepro62 on GitHub · 2026-11-24 19:26 UTC · original
Full-suite run at the new head
c43ac38(on its base9e3831e). One existing test now fails, deterministically.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(that skip is #1651, unrelated): 764 passed, 1 failed. Same result twice, once with nothing else running on the machine.disk_free_space_ex_reports_pls_quota(crates/xcl/tests/pls_quota.rs:129):GetDiskFreeSpaceExWreturns 0 (left: 0, right: 0onassert_ne!).6caef61passed that test (full suite on the AMD Radeon integrated GPU of the 9800X3D: 0 failed). So the change is the latest commit.Cause (from reading the diff)
..that climbs out of theS:(PLS) mount to work and to report the host's free space, not the PLS quota:c43ac38now refuses traversal that leaves a mount root (classify->Target::Game { rel: ".." }, as in the newtranslated_mount_validates_path_against_mount_root_and_rejects_traversal).S:\..\pls-otheris exactly that case, so the call now fails.S:\..\pls-othershould keep resolving (and the new check is too broad), or it should be refused andpls_quota.rsneeds that case changed to expect failure. That's a call for you or the maintainers; I haven't changed anything.Not tested
pls_quotadid not run on this head (29 ignored instead of 41).AI use
@DavidM1911 on GitHub · 2026-11-24 19:32 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!
@Toons29 on GitHub · 2026-11-25 03:34 UTC · original
Regression run of
c43ac386on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@ -298,1 +368,3 @@return Target::Game { rel: abs[self.game_root.len() + 1..].to_string() };let skip = abs.len().saturating_sub(rest.len());let rel_str = abs[skip..].trim_start_matches('\\');if let Some(clean) = clean_rel(rel_str) {@gut0to on GitHub · 2026-11-24 18:00 UTC · original
Could the boundary also be enforced for translated mounts? With a
G:mount rooted atC:\mount,G:\..\outside.txtmaps toC:\mount\..\outside.txt;full_pathresolves it toC:\outside.txt, andTarget::Translatedlater reachesDecision::Usewithoutclean_rel. A console path can therefore escape its mapped root despite this traversal check. Please validate translated paths against their mount root before using them. AI-assisted review: I traced this throughapply_mounts,classify_with, andopen_decision_for.@ -298,1 +368,3 @@return Target::Game { rel: abs[self.game_root.len() + 1..].to_string() };let skip = abs.len().saturating_sub(rest.len());let rel_str = abs[skip..].trim_start_matches('\\');if let Some(clean) = clean_rel(rel_str) {@slopgobblercobbler on GitHub · 2026-11-24 18:27 UTC · original
Addressed in commit
c43ac38: tracked the mount target through apply_mounts and enforced root boundary validation in classify_with. If an absolutised translated path escapes its mapped mount root (whether a custom translated mount or a game mount rooted elsewhere), it is rejected as out-of-bounds (clean_rel / Target::Game { rel: ..\ }) and returns ERROR_PATH_NOT_FOUND from open_decision, rather than escaping via Target::Translated. Added unit test translated_mount_validates_path_against_mount_root_and_rejects_traversal verifying traversal rejection across both custom and game mounts.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.