HLE/media: block mixed-slash UNC, NT object, and backslash file: URL bypasses #484

Open
AscilCH wants to merge 1 commit from upstream-pr/484 into main
AscilCH commented 2026-11-25 01:23:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T01:23:08Z.


Problem

media::local() in crates/victory-hle/src/modules/media.rs is supposed to block all non-local URLs and network shares before forwarding a URL to the host's Media Foundation source resolver. Several Windows-valid SMB/UNC path forms bypassed the filter and returned Ok(...) with the unmodified URL:

  • Mixed-slash UNC prefixes: \/evil.example\share\a.mp4 and /\evil.example/share/a.mp4 (only exact \\ and // were checked).
  • NT object namespace paths: \??\UNC\evil.example\share\a.mp4 (fell through to the relative-path branch).
  • file: URL UNC forms: file://\evil.example\share\a.mp4 (host_of returned "" on the leading backslash), file:\\evil.example\share\a.mp4 (strip_prefix("//") returned None), file:////evil.example/share/a.mp4, percent-encoded file:///%5c%5cevil.example/share/a.mp4, and drive-less file://localhost/share/a.mp4 — all hit !drive(&path) and returned Ok(with_nul(url)).

Fix

  • Reject any two-separator prefix (\\, //, \/, /\) other than verbatim drive paths (\\?\X:...) and reject NT object prefixes (\??\, /??/).
  • Parse two-separator authorities for file: URLs (both / and \), refuse backslash/extra-slash/percent-encoded UNC or NT targets after the authority, and require a drive path for file://localhost/....
  • Use case-insensitive UNC prefix stripping when logging refused hosts.
  • Add synthetic unit test mixed_slash_nt_and_file_unc_bypasses_are_refused.

Verification

  • cargo test -p victory-hle --locked media::tests: 3 passed, 0 failed
  • cargo xtask policy: 169 files ok
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594944473 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/484). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T01:23:08Z. --- ## Problem `media::local()` in `crates/victory-hle/src/modules/media.rs` is supposed to block all non-local URLs and network shares before forwarding a URL to the host's Media Foundation source resolver. Several Windows-valid SMB/UNC path forms bypassed the filter and returned `Ok(...)` with the unmodified URL: - Mixed-slash UNC prefixes: `\/evil.example\share\a.mp4` and `/\evil.example/share/a.mp4` (only exact `\\` and `//` were checked). - NT object namespace paths: `\??\UNC\evil.example\share\a.mp4` (fell through to the relative-path branch). - `file:` URL UNC forms: `file://\evil.example\share\a.mp4` (`host_of` returned `""` on the leading backslash), `file:\\evil.example\share\a.mp4` (`strip_prefix("//")` returned `None`), `file:////evil.example/share/a.mp4`, percent-encoded `file:///%5c%5cevil.example/share/a.mp4`, and drive-less `file://localhost/share/a.mp4` — all hit `!drive(&path)` and returned `Ok(with_nul(url))`. ## Fix - Reject any two-separator prefix (`\\`, `//`, `\/`, `/\`) other than verbatim drive paths (`\\?\X:...`) and reject NT object prefixes (`\??\`, `/??/`). - Parse two-separator authorities for `file:` URLs (both `/` and `\`), refuse backslash/extra-slash/percent-encoded UNC or NT targets after the authority, and require a drive path for `file://localhost/...`. - Use case-insensitive `UNC` prefix stripping when logging refused hosts. - Add synthetic unit test `mixed_slash_nt_and_file_unc_bypasses_are_refused`. ## Verification - `cargo test -p victory-hle --locked media::tests`: 3 passed, 0 failed - `cargo xtask policy`: 169 files ok - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings`: clean *(AI-assisted; synthetic unit tests only, no game data.)*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/484:upstream-pr/484'
git switch 'upstream-pr/484'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/484'
git switch 'upstream-pr/484'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/484'
git switch 'upstream-pr/484'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/484'
git switch 'main'
git merge --squash 'upstream-pr/484'
git switch 'main'
git merge --ff-only 'upstream-pr/484'
git switch 'main'
git merge 'upstream-pr/484'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!484
No description provided.