HLE: prevent automatic WinHTTP redirects #997
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!997
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-997"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Hiiva on GitHub · 2026-11-24 14:47 UTC · original
hiiva/winhttp-no-redirect-upstream→main· +372 −8 · 2 files · 1 commits · closed without mergingWinHTTP can follow a redirect returned by an allowed loopback server inside the host implementation, without another call through the
WinHttpConnectguard.Set
WINHTTP_OPTION_REDIRECT_POLICY_NEVERbefore returning a new session. Later redirect-policy changes on sessions or requests still applyNEVER. If the host cannot enforce the policy, close the handle and preserve the option failure.The existing destination and proxy guards remain in place. The option type, supported handles, and behavior follow Microsoft's WinHTTP option documentation.
Synthetic regression coverage:
NEVER, and make zero connections to the second listener.WinHttpOpenandWinHttpSetOptionresolve to the guarded exports.The redirect regression fails with the guard disabled: all four requests reach the second local listener and return 200. With the guard restored, all four return 307 without following the redirect.
Validation:
cargo test -p victory-hle modules::net:: -- --nocapture: four tests pass, including the isolated child check.cargo test -p victory-hle --features diagnostics modules::net:: -- --nocapture: four tests pass.cargo clippy -p victory-hle --all-targets --features diagnostics -- -D warnings: passes.cargo xtask policy: passes.@Zipettte on GitHub · 2026-11-24 15:12 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
7d1a0a5:cargo test -p victory-hlepasses, 98 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 01:25 UTC · original
Automated triage for the maintainers.
Needs work. The gap is real and this tightens the offline guard rather than loosening it.
WinHttpConnectonly checks the first host, and WinHTTP follows redirects on its own by default, so a loopback server could send a request off the machine. SettingWINHTTP_OPTION_REDIRECT_POLICYto NEVER on every new session inWinHttpOpenis a good fix. Two things need changing first:crates/victory-hle/src/modules/net.rs,no_http_redirectscallsWinHttpCloseHandleon the title's own handle whenWinHttpSetOptionfails. FromWinHttpSetOption, that handle belongs to the title. For example, a connect handle, which does not accept this option, gets closed and later used or closed again by the title (redirect_policy_failure_is_not_reported_as_successasserts exactly this). Close the handle only inWinHttpOpen, where we created it. InWinHttpSetOption, either return success without forwarding (the session's NEVER policy already carries over to its requests), or forward NEVER and return the host's result as is.net_redirect_tests.rs(322 lines) re-runs the test binary as a child process and starts two TCP listeners. Spawning processes from tests needs the maintainer's decision. Without the closing behaviour, the child-process test is not needed. One loopback 307 test plus a policy check is enough.CI: not run on this head.
Generated by Claude Code
Pull request closed