[Ready to merge] HLE: harden storage and xpackage against path traversal and malformed inputs #1375

Open
opened 2026-11-26 04:29:21 +00:00 by github-bot · 2 comments
Owner

@⁠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

**@⁠Xvania7** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/Marvisak/VIctory/issues/1375) 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](https://github.com/Xvania7/VIctory/tree/test/hle-storage-hardening)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:29:21 +00:00
Author
Owner

@⁠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. In crates/victory-hle/src/modules/files.rs, translate resolves . and .. (stopping at the drive root) only for long paths, through verbatim. A shorter path is the root followed by the title's tail unchanged, so X:\..\name reaches the host as <root>\..\name, and Windows resolves that above the drive's folder. Separately, estimate_download in crates/victory-hle/src/modules/xpackage.rs writes *confirm = false before put rejects a null bytes pointer.

Update: the branch is now open as #2318 against 940d32f, so review continues there. Splitting it (traversal fix with its tests; the estimate_download guard; the quota checks; TEST_TITLE_LOCK) would still make it easier to review.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/1375#issuecomment-7159492168) · edited 2026-11-25 12:44 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-25T10:28:58Z at=2026-11-25T12:44:12Z --> Automated triage for the maintainers. Confirmed in `main`. In `crates/victory-hle/src/modules/files.rs`, `translate` resolves `.` and `..` (stopping at the drive root) only for long paths, through `verbatim`. A shorter path is the root followed by the title's tail unchanged, so `X:\..\name` reaches the host as `<root>\..\name`, and Windows resolves that above the drive's folder. Separately, `estimate_download` in `crates/victory-hle/src/modules/xpackage.rs` writes `*confirm = false` before `put` rejects a null `bytes` pointer. Update: the branch is now open as #2318 against `940d32f`, so review continues there. Splitting it (traversal fix with its tests; the `estimate_download` guard; the quota checks; `TEST_TITLE_LOCK`) would still make it easier to review. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 10:28 UTC · original

Rebased test/hle-storage-hardening onto 940d32f and opened #2318 (#2318), passing all 149 victory-hle unit tests, strict clippy, and asset policy.

**@⁠Xvania7** on GitHub · 2026-11-25 10:28 UTC · [original](https://github.com/Marvisak/VIctory/issues/1375#issuecomment-7159754979) Rebased `test/hle-storage-hardening` onto `940d32f` and opened #2318 (https://git.gtahub.st/github/Marvisak--VIctory/pulls/2318), passing all 149 `victory-hle` unit tests, strict clippy, and asset policy.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#1375
No description provided.