Media: refuse a network share after file://localhost too (///server, /%5Cserver, /\\server) #257

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

@⁠sharan104 on GitHub · 2026-11-26 13:31 UTC · original
sharan104:fix/media-audit → main · +22 −6 · 1 files · 1 commits · open

The media source resolver's local-files rule (media.rs, local()) lets any file: URL that names this machine through as a local file. That's because file://localhost//movies is \movies to the host. But the host drops only one of two leading separators after the host name, so these three spellings all reach the host's resolver unchanged, past modules::net:

  • file://localhost///server/share/a.mp4
  • file://localhost/%5Cserver/share/a.mp4
  • file://localhost/\\server/share/a.mp4

They all mean \\server\share\a.mp4.

I checked this with Media Foundation on Windows 11. file://localhost///127.0.0.1/C$/Windows/Media/chimes.wav opens a file through the admin share (S_OK). An unknown server fails with ERROR_BAD_NETPATH, which shows it was treated as a network path. So a title, or a video URL inside its data, could make us open files on network shares, the exact thing this rule is there to refuse.

The gap came from fc0d5e7, which deliberately exempted URLs naming this machine.

Fix: after a host name, one of two leading separators is dropped before the share check, as the host does. The share check now runs whether or not a host is named. file://localhost//server/share and its backslash spelling still pass as local paths (\server\share), as before.

Tests:

  • The three spellings are added to SHARE_URLS. shares_are_refused_however_they_are_spelled fails without the fix (left: Ok("file://localhost///server/share/a.mp4")) and passes with it.
  • the_host_reads_those_spellings_as_shares confirms Media Foundation reads each new spelling as a share.
  • One more local spelling is added to the cases that must still pass.

Results:

  • cargo test -p victory-hle --locked: 155 passed, 0 failed, 2 ignored. The media tests passed 10 out of 10 runs.
  • cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings is clean, with and without --all-features.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 13:31 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/257) `sharan104:fix/media-audit` → `main` · +22 −6 · 1 files · 1 commits · open The media source resolver's local-files rule (`media.rs`, `local()`) lets any `file:` URL that names this machine through as a local file. That's because `file://localhost//movies` is `\movies` to the host. But the host drops only **one** of two leading separators after the host name, so these three spellings all reach the host's resolver unchanged, past `modules::net`: - `file://localhost///server/share/a.mp4` - `file://localhost/%5Cserver/share/a.mp4` - `file://localhost/\\server/share/a.mp4` They all mean `\\server\share\a.mp4`. I checked this with Media Foundation on Windows 11. `file://localhost///127.0.0.1/C$/Windows/Media/chimes.wav` opens a file through the admin share (S_OK). An unknown server fails with `ERROR_BAD_NETPATH`, which shows it was treated as a network path. So a title, or a video URL inside its data, could make us open files on network shares, the exact thing this rule is there to refuse. The gap came from `fc0d5e7`, which deliberately exempted URLs naming this machine. **Fix:** after a host name, one of two leading separators is dropped before the share check, as the host does. The share check now runs whether or not a host is named. `file://localhost//server/share` and its backslash spelling still pass as local paths (`\server\share`), as before. **Tests:** - The three spellings are added to `SHARE_URLS`. `shares_are_refused_however_they_are_spelled` fails without the fix (`left: Ok("file://localhost///server/share/a.mp4")`) and passes with it. - `the_host_reads_those_spellings_as_shares` confirms Media Foundation reads each new spelling as a share. - One more local spelling is added to the cases that must still pass. **Results:** - `cargo test -p victory-hle --locked`: 155 passed, 0 failed, 2 ignored. The media tests passed 10 out of 10 runs. - `cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings` is clean, with and without `--all-features`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The source resolver's rule let any path of a `file:` URL that names this
machine through as a local file, because `file://localhost//movies` is
`\movies` to the host. But the host drops only one of two leading
separators after the host: `file://localhost///server/share`,
`file://localhost/%5Cserver/share` and `file://localhost/\\server/share`
are `\\server\share`, and Media Foundation opens them over the network
(checked here: `file://localhost///127.0.0.1/C$/...` opens a file through
the admin share, and an unknown server fails with ERROR_BAD_NETPATH).
Those went to the host's resolver unchanged, past `modules::net`.

After a host, one of two leading separators is dropped before the share
check, as the host does, and the check now applies with or without a
host. `file://localhost//server/share` and its backslash spelling still
pass as local paths.

The new spellings are in SHARE_URLS: shares_are_refused_however_they_are_spelled
fails without the fix and passes with it, and
the_host_reads_those_spellings_as_shares confirms the host reads each as
a share.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:32:39 +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/257/head:github-bot/gh-257'
git switch 'github-bot/gh-257'

Merge

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