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

Open
Arkenoz wants to merge 1 commit from upstream-pr/3121 into main
Arkenoz commented 2026-11-26 08:58:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-26T08:58:00Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6623072029 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121). Originally posted by [Arkenoz](https://github.com/Arkenoz) on 2026-11-26T08:58:00Z. --- ### 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).
Dukestar69 commented 2026-11-26 10:04:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:09:53Z.

Review: APPROVED


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

<!-- greyfinch-sync:Marvisak/VIctory:review:6071253898 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121#pullrequestreview-6071253898). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:09:53Z. **Review:** APPROVED --- 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).
fuzeofficlal commented 2026-11-26 10:04:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:33:59Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6071625244 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121#pullrequestreview-6071625244). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T09:33:59Z. **Review:** CHANGES_REQUESTED --- 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.
Marvisak commented 2026-11-26 10:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T09:17:41Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7187735760 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7187735760). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T09:17:41Z. --- <!-- 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)_
Arkenoz commented 2026-11-26 11:04:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-26T10:33:04Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189515047 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7189515047). Originally posted by [Arkenoz](https://github.com/Arkenoz) on 2026-11-26T10:33:04Z. --- > 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.
futurepro62 commented 2026-11-26 20:20:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T20:20:32Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7202558802 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3121#issuecomment-7202558802). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T20:20:32Z. --- 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 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/3121:upstream-pr/3121'
git switch 'upstream-pr/3121'

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/3121'
git switch 'upstream-pr/3121'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3121'
git switch 'upstream-pr/3121'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3121'
git switch 'main'
git merge --squash 'upstream-pr/3121'
git switch 'main'
git merge --ff-only 'upstream-pr/3121'
git switch 'main'
git merge 'upstream-pr/3121'
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
Marvisak/VIctory!3119
No description provided.