hle: confine virtual-drive paths and harden storage/package inputs #1447

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

@⁠kunalkhude99 on GitHub · 2026-11-24 18:04 UTC · original
kunalkhude99:fix/issue-1375-hle-storage-hardening → main · +468 −11 · 4 files · 1 commits · closed without merging

Summary:

  • Normalize short virtual-drive paths containing .. so traversal stops at the mounted drive root, while preserving intra-folder relative paths and mixed slash handling.
  • Reject a null bytes out-pointer in XPackageEstimateDownload before any side effects.
  • Add synthetic coverage for path traversal, quota saturation/overflow, unmounted drives, malformed package identifiers/sizes, and concurrent title-state tests.

Root cause:
Short title paths were concatenated directly onto the host folder behind a virtual drive. A path such as X:..\secret.dat therefore resolved above the sandbox. estimate_download also wrote *confirm = false before validating the bytes pointer, and tests sharing the global Title state could clobber each other under a multi-threaded runner.

Fix:

  • Reuse normalize_parts in files::translate for any short path containing ..; each .. pops a component and stops at the drive root. Long paths already used the normalized \\?\ form.
  • Add the null guard in estimate_download before writing outputs.
  • Serialize tests that mutate runtime::Title with TEST_TITLE_LOCK.

Testing:

  • cargo test -p victory-hle
  • cargo clippy -p victory-hle --all-targets -- -D warnings
  • cargo xtask policy

Fixes #1375

**@⁠kunalkhude99** on GitHub · 2026-11-24 18:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1447) `kunalkhude99:fix/issue-1375-hle-storage-hardening` → `main` · +468 −11 · 4 files · 1 commits · closed without merging Summary: - Normalize short virtual-drive paths containing `..` so traversal stops at the mounted drive root, while preserving intra-folder relative paths and mixed slash handling. - Reject a null `bytes` out-pointer in `XPackageEstimateDownload` before any side effects. - Add synthetic coverage for path traversal, quota saturation/overflow, unmounted drives, malformed package identifiers/sizes, and concurrent title-state tests. Root cause: Short title paths were concatenated directly onto the host folder behind a virtual drive. A path such as `X:..\secret.dat` therefore resolved above the sandbox. `estimate_download` also wrote `*confirm = false` before validating the `bytes` pointer, and tests sharing the global `Title` state could clobber each other under a multi-threaded runner. Fix: - Reuse `normalize_parts` in `files::translate` for any short path containing `..`; each `..` pops a component and stops at the drive root. Long paths already used the normalized `\\?\` form. - Add the null guard in `estimate_download` before writing outputs. - Serialize tests that mutate `runtime::Title` with `TEST_TITLE_LOCK`. Testing: - cargo test -p victory-hle - cargo clippy -p victory-hle --all-targets -- -D warnings - cargo xtask policy Fixes #1375
Summary:
- Normalize short virtual-drive paths containing `..` so traversal stops at
  the mounted drive root, while preserving intra-folder relative paths and
  mixed slash handling.
- Reject a null `bytes` out-pointer in `XPackageEstimateDownload` before any
  side effects.
- Add synthetic coverage for path traversal, quota saturation/overflow,
  unmounted drives, malformed package identifiers/sizes, and concurrent
  title-state tests.

Root cause:
Short title paths were concatenated directly onto the host folder behind a
virtual drive. A path such as `X:..\secret.dat` therefore resolved above the
sandbox. `estimate_download` also wrote `*confirm = false` before validating
the `bytes` pointer, and tests sharing the global `Title` state could clobber
each other under a multi-threaded runner.

Fix:
- Reuse `normalize_parts` in `files::translate` for any short path containing
  `..`; each `..` pops a component and stops at the drive root. Long paths
  already used the normalized `\\?\` form.
- Add the null guard in `estimate_download` before writing outputs.
- Serialize tests that mutate `runtime::Title` with `TEST_TITLE_LOCK`.

Testing:
- cargo test -p victory-hle
- cargo clippy -p victory-hle --all-targets -- -D warnings
- cargo xtask policy

Fixes #1375
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:32:06 +00:00
github-bot closed this pull request 2026-11-26 04:32:06 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:40 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #182. Its real fix (.. in a short title path escapes the virtual drive's folder, true in main) is done better by the focused #182, which also keeps trailing separators and leaves \\?\ paths alone. The rest is a null-pointer guard and 400 lines of generated tests.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1447#issuecomment-7148755571) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #182. Its real fix (`..` in a short title path escapes the virtual drive's folder, true in main) is done better by the focused #182, which also keeps trailing separators and leaves `\\?\` paths alone. The rest is a null-pointer guard and 400 lines of generated tests. If this is mistaken, reply here with what was missed (or push a change and say so) 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!1447
No description provided.