[Ready to merge] HLE: harden storage and xpackage against path traversal and malformed inputs #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?
Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-24T17:39:36Z.
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
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:17:25Z.
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
Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T10:28:58Z.
Rebased
test/hle-storage-hardeningonto940d32fand opened #2318 (https://github.com/Marvisak/VIctory/pull/2318), passing all 149victory-hleunit tests, strict clippy, and asset policy.