Skip to content

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

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

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

Conversation

@kunalkhude99

Copy link
Copy Markdown

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 Marvisak#1375
@Marvisak

Copy link
Copy Markdown
Owner

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 Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants