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

Closed
github-bot wants to merge 1 commit from gh-pr/2318/head into gh-pr/2318/base
Owner

@⁠Xvania7 on GitHub · 2026-11-25 10:28 UTC · original
Xvania7:fix/issue-1375-hle-storage-hardening → main · +471 −11 · 4 files · 1 commits · closed without merging

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
**@⁠Xvania7** on GitHub · 2026-11-25 10:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2318) `Xvania7:fix/issue-1375-hle-storage-hardening` → `main` · +471 −11 · 4 files · 1 commits · closed without merging ## 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:06 +00:00
github-bot closed this pull request 2026-11-26 05:02:06 +00:00
Author
Owner

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

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** on GitHub · 2026-11-25 10:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2318#issuecomment-7160365611) 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:26 UTC · original

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** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2318#issuecomment-7166849748) <!-- victory-triage v1 head=a1f8e1d84b979dc6cf333f875c63b448037ceb7f verdict=merge-candidate at=2026-11-25T15:26:00Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:08 UTC · original

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** on GitHub · 2026-11-25 22:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2318#issuecomment-7175984758) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!2318
No description provided.