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

Open
opened 2026-11-26 04:20:57 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 16:08 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 16:08 UTC · [original](https://github.com/Marvisak/VIctory/issues/1141) ### 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:57 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-24 16:09 UTC · original

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.

**@⁠pickles976** on GitHub · 2026-11-24 16:09 UTC · [original](https://github.com/Marvisak/VIctory/issues/1141#issuecomment-7137216699) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:07 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/1141#issuecomment-7159262094) <!-- 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)_
This discussion has been locked. Commenting is limited to contributors.
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#1141
No description provided.