HLE: reject null handle in WinHttpSetOption proxy path and expand net.rs tests (1 -> 17) #1141

Open
opened 2026-11-24 16:08:41 +00:00 by geiyiliyabumo · 2 comments
geiyiliyabumo commented 2026-11-24 16:08:41 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T16:08:41Z.


Summary

Fixes a null-handle check in WinHttpSetOption (WINHTTP_OPTION_PROXY) in crates/victory-hle/src/modules/net.rs and expands deterministic synthetic unit tests from 1 to 17 passing tests.

Because we have been tracking our branches per issue, this CI-green branch is ready on my fork (and now that pull_request_creation_policy is all, ready for PR):

  • Branch: geiyiliyabumo/VIctory@test/hle-net-audit
  • Commit: geiyiliyabumo/VIctory@d30bed4 (based on main ffe310e)

Changes (crates/victory-hle/src/modules/net.rs)

  • Bug fix: WinHttpSetOption previously returned 1 (success) for WINHTTP_OPTION_PROXY even when handle.is_null(); it now forwards null handles to the host to refuse.
  • Tests (1 -> 17 synthetic): covers loopback filtering (IPv4/IPv6), local name matching, narrow/UTF-16 string reading, export table integrity, raw/sockaddr decoding, namespace/forward/reverse DNS isolation, ConnectEx/WSASendMsg HLE routing, proxy auto-detection failure, WinHttp local-only enforcement, bind(0.0.0.0) narrowing to loopback, connect vetting by address/name, and non-local datagram dropping.

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-hle --locked -- net::: 17 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586133605 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1141). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T16:08:41Z. --- ### Summary Fixes a null-handle check in `WinHttpSetOption` (`WINHTTP_OPTION_PROXY`) in `crates/victory-hle/src/modules/net.rs` and expands deterministic synthetic unit tests from 1 to **17 passing tests**. Because we have been tracking our branches per issue, this CI-green branch is ready on my fork (and now that `pull_request_creation_policy` is `all`, ready for PR): - **Branch**: `geiyiliyabumo/VIctory@test/hle-net-audit` - **Commit**: `geiyiliyabumo/VIctory@d30bed4` (based on `main` `ffe310e`) ### Changes (`crates/victory-hle/src/modules/net.rs`) - **Bug fix**: `WinHttpSetOption` previously returned `1` (success) for `WINHTTP_OPTION_PROXY` even when `handle.is_null()`; it now forwards null handles to the host to refuse. - **Tests (1 -> 17 synthetic)**: covers loopback filtering (IPv4/IPv6), local name matching, narrow/UTF-16 string reading, export table integrity, raw/sockaddr decoding, namespace/forward/reverse DNS isolation, `ConnectEx`/`WSASendMsg` HLE routing, proxy auto-detection failure, `WinHttp` local-only enforcement, `bind(0.0.0.0)` narrowing to loopback, connect vetting by address/name, and non-local datagram dropping. ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-hle --locked -- net::`: **17 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
pickles976 commented 2026-11-24 17:04:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-24T16:09:42Z.


Justification from the sibling runtime for why the null-rejection belongs at the entry, not in the proxy branch body only: in ivall/xcl's offline mode (XCL_NETWORK=0) WinHttpConnect returns a null handle by design (the deliberate-offline shim, netoff.rs — connect stubs to null so the title's network paths fail cleanly), which means in that mode every subsequent WinHttp* call arrives with a null handle — the null path is not an attacker corner there, it is the happy path. A runtime whose offline/network-disabled mode is a supported configuration has to treat "option call on null handle" as a designed-for input returning the documented failure, never as an unreachable state. Our equivalent surface (only Connect/SendRequest bound; everything else to arg-blind stubs) is safe by construction today, but if we ever expand the shim table your fix is the pattern to copy — handle check first, branch second.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137216699 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1141#issuecomment-7137216699). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T16:09:42Z. --- Justification from the sibling runtime for why the null-rejection belongs at the entry, not in the proxy branch body only: in ivall/xcl's offline mode (`XCL_NETWORK=0`) `WinHttpConnect` **returns a null handle by design** (the deliberate-offline shim, `netoff.rs` — connect stubs to null so the title's network paths fail cleanly), which means in that mode **every** subsequent `WinHttp*` call arrives with a null handle — the null path is not an attacker corner there, it is the happy path. A runtime whose offline/network-disabled mode is a supported configuration has to treat "option call on null handle" as a designed-for input returning the documented failure, never as an unreachable state. Our equivalent surface (only Connect/SendRequest bound; everything else to arg-blind stubs) is safe by construction today, but if we ever expand the shim table your fix is the pattern to copy — handle check first, branch second.
Marvisak commented 2026-11-25 10:07:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:07:40Z.


Automated triage for the maintainers.

Confirmed on main: WinHttpSetOption in crates/victory-hle/src/modules/net.rs returns success for WINHTTP_OPTION_PROXY before looking at the handle, so a null handle is accepted there, while every other option goes to the host, which refuses it. It is minor, since the proxy is ignored either way, but the success return is wrong. Open pull request #1213 by the same author carries the fix and the added tests, so review can continue there.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159262094 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1141#issuecomment-7159262094). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:07:40Z. --- <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T16:09:42Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. Confirmed on `main`: `WinHttpSetOption` in `crates/victory-hle/src/modules/net.rs` returns success for `WINHTTP_OPTION_PROXY` before looking at the handle, so a null handle is accepted there, while every other option goes to the host, which refuses it. It is minor, since the proxy is ignored either way, but the success return is wrong. Open pull request #1213 by the same author carries the fix and the added tests, so review can continue there. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
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#1141
No description provided.