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

Open
github-bot wants to merge 1 commit from github-bot/gh-484 into main AGit
Owner

@⁠AscilCH on GitHub · 2026-11-25 01:23 UTC · original
AscilCH:fix/hle-media-local-url-unc-bypass → main · +143 −12 · 1 files · 1 commits · open

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.)

**@⁠AscilCH** on GitHub · 2026-11-25 01:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/484) `AscilCH:fix/hle-media-local-url-unc-bypass` → `main` · +143 −12 · 1 files · 1 commits · open ## 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.)*
- Reject all two-separator UNC/device prefixes (`\/`, `/\`, `\\.\`, `//?/`)
  and NT object namespace prefixes (`\??\`, `/??/`) in `media::local()`,
  allowing only verbatim drive paths (`\\?\X:...`).
- Handle case-insensitive `UNC\`/`UNC/` prefix stripping when reporting the
  refused host.
- Normalize two-separator authorities in `file:` URLs and refuse backslash,
  extra-slash, percent-encoded UNC/NT, and drive-less `localhost` SMB forms
  (`file://\host\share`, `file:\\host\share`, `file:////host/share`,
  `file:///%5c%5chost/share`, `file://localhost/share`) instead of falling
  through with the unmodified URL.
- Add synthetic unit tests covering all bypass forms and valid local controls.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:25 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/484/head:github-bot/gh-484'
git switch 'github-bot/gh-484'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-484'
git switch 'github-bot/gh-484'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-484'
git switch 'github-bot/gh-484'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-484'
git switch 'main'
git merge --squash 'github-bot/gh-484'
git switch 'main'
git merge --ff-only 'github-bot/gh-484'
git switch 'main'
git merge 'github-bot/gh-484'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.