HLE media: block UNC share bypasses for localhost and \??\ file URLs #3121

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

@⁠Arkenoz on GitHub · 2026-11-26 08:58 UTC · original
Arkenoz:fix/media-local-unc-bypasses → main · +76 −4 · 1 files · 1 commits · open

Summary

Closes two remaining UNC share bypasses in media::local (crates/victory-hle/src/modules/media.rs) following up on #207:

  1. file://localhost/... with extra leading separators: this_machine == true previously skipped share(&whole) completely. Because shlwapi.dll!PathCreateFromUrlW consumes only a single leading separator after localhost, URLs such as file://localhost///server/share/a.mp4, file://localhost/\\server/share/a.mp4, and file://localhost/%5C%5Cserver/share/a.mp4 resolve to remote UNC paths (\\server\share\a.mp4 / \\\server\share\a.mp4) and were allowed through. media::local now strips one leading separator when this_machine is set and still runs share(...) on the remainder, keeping file://localhost//server/share/a.mp4 (\server\share\a.mp4) local.
  2. Percent-encoded \??\ object-manager prefixes in file: URLs: URLs like file:///%3F%3F/UNC/server/share/a.mp4 decode to \??\UNC\server\share\a.mp4 in PathCreateFromUrlW without starting with two separators. media::local now rejects decoded \??\ paths unless followed by a drive letter, stripping UNC\ case-insensitively when extracting the host.

Testing

  • Added localhost_and_object_prefix_file_urls_are_refused (verified failing before the fix and passing after) and Windows oracle test the_host_reads_localhost_and_object_prefix_share_urls_as_shares against shlwapi.dll!PathCreateFromUrlW.
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs — passed
  • cargo clippy --workspace --all-targets -- -D warnings — passed
  • cargo check --workspace --all-targets — passed
  • cargo xtask policy — passed (asset policy: 191 files ok)
  • cargo test -p victory-hle --locked — passed (154 lib + fidelityfx + no_dll_planting)

Coordination & AI disclosure

  • Claimed in #1633.
  • AI-assisted (Antigravity / Gemini 4 Neon).
**@⁠Arkenoz** on GitHub · 2026-11-26 08:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121) `Arkenoz:fix/media-local-unc-bypasses` → `main` · +76 −4 · 1 files · 1 commits · open ### Summary Closes two remaining UNC share bypasses in `media::local` (`crates/victory-hle/src/modules/media.rs`) following up on #207: 1. **`file://localhost/...` with extra leading separators:** `this_machine == true` previously skipped `share(&whole)` completely. Because `shlwapi.dll!PathCreateFromUrlW` consumes only a single leading separator after `localhost`, URLs such as `file://localhost///server/share/a.mp4`, `file://localhost/\\server/share/a.mp4`, and `file://localhost/%5C%5Cserver/share/a.mp4` resolve to remote UNC paths (`\\server\share\a.mp4` / `\\\server\share\a.mp4`) and were allowed through. `media::local` now strips one leading separator when `this_machine` is set and still runs `share(...)` on the remainder, keeping `file://localhost//server/share/a.mp4` (`\server\share\a.mp4`) local. 2. **Percent-encoded `\??\` object-manager prefixes in `file:` URLs:** URLs like `file:///%3F%3F/UNC/server/share/a.mp4` decode to `\??\UNC\server\share\a.mp4` in `PathCreateFromUrlW` without starting with two separators. `media::local` now rejects decoded `\??\` paths unless followed by a drive letter, stripping `UNC\` case-insensitively when extracting the host. ### Testing - Added `localhost_and_object_prefix_file_urls_are_refused` (verified failing before the fix and passing after) and Windows oracle test `the_host_reads_localhost_and_object_prefix_share_urls_as_shares` against `shlwapi.dll!PathCreateFromUrlW`. - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs` — passed - `cargo clippy --workspace --all-targets -- -D warnings` — passed - `cargo check --workspace --all-targets` — passed - `cargo xtask policy` — passed (`asset policy: 191 files ok`) - `cargo test -p victory-hle --locked` — passed (`154` lib + `fidelityfx` + `no_dll_planting`) ### Coordination & AI disclosure - Claimed in #1633. - AI-assisted (Antigravity / Gemini 4 Neon).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:03:05 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:09 UTC · original · approved these changes

Verified against origin/main (63bcca4):

  • cargo test -p victory-hle --lib modules::media:: -- --test-threads=1: 7/7 passed (including localhost_and_object_prefix_file_urls_are_refused and the_host_reads_localhost_and_object_prefix_share_urls_as_shares).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly closes the localhost and \??\ UNC share bypasses in media.rs.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121#pullrequestreview-6071253898) · **approved these changes** Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-hle --lib modules::media:: -- --test-threads=1`: 7/7 passed (including `localhost_and_object_prefix_file_urls_are_refused` and `the_host_reads_localhost_and_object_prefix_share_urls_as_shares`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly closes the `localhost` and `\??\` UNC share bypasses in `media.rs`. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 09:17 UTC · original

Automated triage for the maintainers.

Merge candidate. This makes the URL rule in media::local (crates/victory-hle/src/modules/media.rs) stricter and loosens nothing. On main, !this_machine && share(&whole) skipped the share check for every file://localhost/... URL. Now the check runs on every non-drive file: path, and for localhost it runs after removing one leading separator. That refuses everything main refused and also file://localhost///server/..., file://localhost/\\server/... and the percent-encoded spelling. The new \??\ check on the decoded path refuses file:///%3F%3F/UNC/server/.... I found no local path that is now wrongly refused, and the controls (localhost//, \??\C:) still pass. The Windows test reads PathCreateFromUrlW's own output, so it backs the claim about host behaviour. Nit: its localhost// assertion repeats one in the_host_reads_those_spellings_as_shares.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 09:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7187735760) <!-- victory-triage v1 head=afd63d5e8888054b1c46a6820cb2c6909839c4fe verdict=merge-candidate at=2026-11-26T09:17:40Z --> Automated triage for the maintainers. **Merge candidate.** This makes the URL rule in `media::local` (`crates/victory-hle/src/modules/media.rs`) stricter and loosens nothing. On `main`, `!this_machine && share(&whole)` skipped the share check for every `file://localhost/...` URL. Now the check runs on every non-drive `file:` path, and for `localhost` it runs after removing one leading separator. That refuses everything `main` refused and also `file://localhost///server/...`, `file://localhost/\\server/...` and the percent-encoded spelling. The new `\??\` check on the decoded path refuses `file:///%3F%3F/UNC/server/...`. I found no local path that is now wrongly refused, and the controls (`localhost//`, `\??\C:`) still pass. The Windows test reads `PathCreateFromUrlW`'s own output, so it backs the claim about host behaviour. Nit: its `localhost//` assertion repeats one in `the_host_reads_those_spellings_as_shares`. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 09:33 UTC · original · requested changes

Verified afd63d5e locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings: clean (3.14s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory-hle --locked: 156 passed, 0 failed (154 lib including all 7 modules::media::tests + 1 fidelityfx + 1 no_dll_planting, 5.00s).
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs: clean.

The added effective and \??\ checks close the submitted file://localhost///..., file://localhost/\\..., file://localhost/%5C%5C..., and file:///%3F%3F/UNC/... cases. However, for non-drive file: URLs (media.rs:92-116), local() validates decoded Rust views (whole/path) and then returns Ok(with_nul(url)), handing the original raw UTF-16 URL to Media Foundation to re-parse (for example with mixed encoded separators or namespace combinations). Please validate the host-converted path (or hand Media Foundation the exact normalized local path that passed the check) consistently across both resolver entry points, and expand the Windows conversion coverage for mixed separators and percent-encoded slashes.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121#pullrequestreview-6071625244) · **requested changes** Verified `afd63d5e` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings`: clean (`3.14s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). - `cargo test -p victory-hle --locked`: 156 passed, 0 failed (`154` lib including all 7 `modules::media::tests` + `1` fidelityfx + `1` no_dll_planting, `5.00s`). - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs`: clean. The added `effective` and `\??\` checks close the submitted `file://localhost///...`, `file://localhost/\\...`, `file://localhost/%5C%5C...`, and `file:///%3F%3F/UNC/...` cases. However, for non-drive `file:` URLs (`media.rs:92-116`), `local()` validates decoded Rust views (`whole`/`path`) and then returns `Ok(with_nul(url))`, handing the original raw UTF-16 URL to Media Foundation to re-parse (for example with mixed encoded separators or namespace combinations). Please validate the host-converted path (or hand Media Foundation the exact normalized local path that passed the check) consistently across both resolver entry points, and expand the Windows conversion coverage for mixed separators and percent-encoded slashes.
Author
Owner

@⁠Arkenoz on GitHub · 2026-11-26 10:33 UTC · original

Verified afd63d5e locally on Windows 11 x64:

* `cargo clippy --all-targets --locked -- -D warnings`: clean (`3.14s`).

* `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`).

* `cargo test -p victory-hle --locked`: 156 passed, 0 failed (`154` lib including all 7 `modules::media::tests` + `1` fidelityfx + `1` no_dll_planting, `5.00s`).

* `rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs`: clean.

The added effective and \??\ checks close the submitted file://localhost///..., file://localhost/\\..., file://localhost/%5C%5C..., and file:///%3F%3F/UNC/... cases. However, for non-drive file: URLs (media.rs:92-116), local() validates decoded Rust views (whole/path) and then returns Ok(with_nul(url)), handing the original raw UTF-16 URL to Media Foundation to re-parse (for example with mixed encoded separators or namespace combinations). Please validate the host-converted path (or hand Media Foundation the exact normalized local path that passed the check) consistently across both resolver entry points, and expand the Windows conversion coverage for mixed separators and percent-encoded slashes.

Thanks for the thorough review and local verification! That's a good point about validating/passing the host-normalized path rather than the raw UTF-16 URL. Since this PR is intentionally kept minimal and already marked as a merge candidate, I'd prefer to keep it focused on closing the localhost and \??\ bypasses and leave normalizing the return path across both resolver entry points for a separate follow-up PR.

**@⁠Arkenoz** on GitHub · 2026-11-26 10:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7189515047) > Verified `afd63d5e` locally on Windows 11 x64: > > * `cargo clippy --all-targets --locked -- -D warnings`: clean (`3.14s`). > > * `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). > > * `cargo test -p victory-hle --locked`: 156 passed, 0 failed (`154` lib including all 7 `modules::media::tests` + `1` fidelityfx + `1` no_dll_planting, `5.00s`). > > * `rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs`: clean. > > > The added `effective` and `\??\` checks close the submitted `file://localhost///...`, `file://localhost/\\...`, `file://localhost/%5C%5C...`, and `file:///%3F%3F/UNC/...` cases. However, for non-drive `file:` URLs (`media.rs:92-116`), `local()` validates decoded Rust views (`whole`/`path`) and then returns `Ok(with_nul(url))`, handing the original raw UTF-16 URL to Media Foundation to re-parse (for example with mixed encoded separators or namespace combinations). Please validate the host-converted path (or hand Media Foundation the exact normalized local path that passed the check) consistently across both resolver entry points, and expand the Windows conversion coverage for mixed separators and percent-encoded slashes. Thanks for the thorough review and local verification! That's a good point about validating/passing the host-normalized path rather than the raw UTF-16 URL. Since this PR is intentionally kept minimal and already marked as a merge candidate, I'd prefer to keep it focused on closing the `localhost` and `\??\` bypasses and leave normalizing the return path across both resolver entry points for a separate follow-up PR.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 20:20 UTC · original

NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, since none of them names a GPU run. Tested exact head afd63d5 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: localhost_and_object_prefix_file_urls_are_refused, the_host_reads_localhost_and_object_prefix_share_urls_as_shares.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 20:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7202558802) NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, since none of them names a GPU run. Tested exact head `afd63d5` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **868 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `localhost_and_object_prefix_file_urls_are_refused`, `the_host_reads_localhost_and_object_prefix_share_urls_as_shares`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
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/3121/head:github-bot/gh-3121'
git switch 'github-bot/gh-3121'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3121'
git switch 'github-bot/gh-3121'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3121'
git switch 'github-bot/gh-3121'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3121'
git switch 'main'
git merge --squash 'github-bot/gh-3121'
git switch 'main'
git merge --ff-only 'github-bot/gh-3121'
git switch 'main'
git merge 'github-bot/gh-3121'
git push origin 'main'
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!3121
No description provided.