[Ready to merge] HLE: harden storage and xpackage against path traversal and malformed inputs #1375
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#1375
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Xvania7 on GitHub · 2026-11-24 17:39 UTC · original
Summary
This change hardens the Xbox HLE virtual filesystem (crates/victory-hle/src/modules/files.rs, storage.rs) and package management (xpackage.rs) against path traversal attacks, malformed paths, quota underflows, and truncated or corrupted package inputs.
Vulnerabilities & Bugs Fixed
Virtual Drive Path Traversal:
On the console, virtual drives (G:, T:, and the title storage drive) represent volume roots where .. cannot escape above the root.
In files::translate, paths shorter than LONG (248 chars) previously concatenated the title-supplied tail directly to the host folder without component normalization. Title paths containing .. segments (e.g. X:..\secret.dat) could traverse above the sandbox into parent host directories.
Added component normalization via normalize_parts: .. segments stop at the root of the mounted drive, confining all operations strictly within the target host directory, while still properly resolving intra-folder relative paths (e.g. X:\sub..\save.dat) and normalizing mixed slashes.
Side-effect on Null Parameter in estimate_download:
xpackage::estimate_download previously mutated *confirm to false before validating whether the bytes out-pointer was non-null. Added an early null guard returning E_INVALIDARG without side-effects.
Storage Quota & Boundary Integrity:
Hardened space_info and prompt_for_space validation against extreme request sizes (u64::MAX), non-existent drives, unmounted storage roots, and host disk quota saturation.
Test Harness Concurrency Isolation:
Added TEST_TITLE_LOCK in runtime.rs to prevent multi-threaded test runners from clobbering the global Title state during concurrent test execution.
Verification
Added 6 comprehensive synthetic unit tests across storage.rs and xpackage.rs:
modules::storage::tests::path_traversal_cannot_escape_storage_root
modules::storage::tests::mixed_path_separators_resolve_correctly
modules::storage::tests::storage_quota_enforcement_and_overflow
modules::storage::tests::unmounted_and_nonexistent_drive_access
modules::xpackage::tests::truncated_and_corrupted_package_identifiers_are_rejected
modules::xpackage::tests::invalid_data_sizes_and_null_buffers_are_safely_handled
Test & CI status:
cargo test -p victory-hle (100 passed, 0 failed)
cargo clippy -p victory-hle --all-targets -- -D warnings (clean)
cargo xtask policy (154 files ok)
Branch: test/hle-storage-hardening
@Marvisak on GitHub · 2026-11-25 10:17 UTC · original · edited 2026-11-25 12:44 UTC
Automated triage for the maintainers.
Confirmed in
main. Incrates/victory-hle/src/modules/files.rs,translateresolves.and..(stopping at the drive root) only for long paths, throughverbatim. A shorter path is the root followed by the title's tail unchanged, soX:\..\namereaches the host as<root>\..\name, and Windows resolves that above the drive's folder. Separately,estimate_downloadincrates/victory-hle/src/modules/xpackage.rswrites*confirm = falsebeforeputrejects a nullbytespointer.Update: the branch is now open as #2318 against
940d32f, so review continues there. Splitting it (traversal fix with its tests; theestimate_downloadguard; the quota checks;TEST_TITLE_LOCK) would still make it easier to review.Generated by Claude Code
@Xvania7 on GitHub · 2026-11-25 10:28 UTC · original
Rebased
test/hle-storage-hardeningonto940d32fand opened #2318 (#2318), passing all 149victory-hleunit tests, strict clippy, and asset policy.