Skip to content

HLE: harden storage and xpackage against path traversal and malformed inputs (fixes #1375) - #2318

Closed
Xvania7 wants to merge 1 commit into
Marvisak:mainfrom
Xvania7:fix/issue-1375-hle-storage-hardening
Closed

Xvania7 wants to merge 1 commit into
Marvisak:mainfrom
Xvania7:fix/issue-1375-hle-storage-hardening

Conversation

@Xvania7

@Xvania7 Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown

Summary

Rebased test/hle-storage-hardening (324dc7b) cleanly onto main (940d32f) as requested in #1375.

  • crates/victory-hle/src/modules/files.rs: resolves . and .. for short title paths as well as verbatim paths so traversal cannot escape the mounted drive root.
  • crates/victory-hle/src/modules/xpackage.rs: guards estimate_download null pointers before writing *confirm = false and validates malformed/truncated package identifiers.
  • crates/victory-hle/src/modules/storage.rs & runtime.rs: storage quota checks and unit tests.

Tests

  • cargo test -p victory-hle --lib — 149 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets -- -D warnings — 0 warnings
  • cargo xtask policy — 182 files ok

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (940d32f):

  • storage (20/20) and files (8/8) tests pass, cargo clippy -p victory-hle --all-targets -- -D warnings has 0 warnings, and cargo xtask policy passes (183 files ok).
  • Parallel test race in modules::xpackage::tests: Running cargo test -p victory-hle xpackage with default parallel test threads fails:
    thread 'modules::xpackage::tests::the_installation_is_complete_and_alone' panicked at crates\victory-hle\src\modules\xpackage.rs:367:9:
    assertion `left == right` failed
      left: "00000000"
     right: "639AA8DD"
    
    Running with -- --test-threads=1 passes 4/4, confirming the new xpackage::tests race on shared global runtime state with the_installation_is_complete_and_alone. Serializing the xpackage::tests that touch global runtime state with a shared Mutex should eliminate this flake under default cargo test.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HLE: harden storage/xpackage against path traversal — normalize_parts resolves . and .. inside verbatim() (.. stops at root) (+468). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Security-relevant hardening; good.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks for catching that! Locked crate::runtime::TEST_TITLE_LOCK in the_installation_is_complete_and_alone and amended (a1f8e1d). Re-ran cargo test -p victory-hle --lib xpackage 5x under default parallel threads (4/4 each), cargo test -p victory-hle --lib (149/149), cargo clippy -p victory-hle --all-targets -- -D warnings (0 warnings), and cargo xtask policy (182 files ok).

@Xvania7
Xvania7 force-pushed the fix/issue-1375-hle-storage-hardening branch from 54afd5b to a1f8e1d Compare November 25, 2026 10:55

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (worth a look). On main, files::translate resolved . and .. (stopping at the root) only for long paths, in verbatim; short paths went to the host as they were, so a title path like X:\..\file was resolved by Win32 to the parent of the mounted folder. This PR moves that resolution into normalize_parts and uses it whenever the tail has a .. part, so short paths behave like long ones. It also stops estimate_download in xpackage.rs from writing *confirm before failing on a null bytes. I checked the new branch against the existing X:name and verbatim-prefix handling and the vtable offsets the new tests call; the tests take a new TEST_TITLE_LOCK around the global title. The xpackage tests mostly pin existing behaviour and could be trimmed. Linked issue #1375 is confirmed. CI: passing.


Generated by Claude Code

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing in favour of #182 for the traversal fix (the bug is real). Here the has_traversal branch drops a trailing separator, so X:\a\..\b\ becomes <root>\b and a file opened with a trailing backslash succeeds where Windows fails, and it also rewrites \\?\-prefixed paths, which #182 deliberately leaves alone. The xpackage null guard changes behaviour only for a null out pointer, and most of the new tests pin existing behaviour.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants