HLE/net: refuse a WSAConnectByList count the list cannot back #476

Closed
github-bot wants to merge 1 commit from gh-pr/476/head into gh-pr/476/base
Owner

@⁠iloveslopware on GitHub · 2026-11-25 01:22 UTC · original
iloveslopware:wsaconnectbylist-count → main · +42 −0 · 1 files · 1 commits · closed without merging

WSAConnectByList turned iAddressCount into a &[SocketAddress] of that length before any address was vetted, so a list holding one 16-byte entry with iAddressCount = 0x7FFFFFFF produced a ~34 GB slice and read far past the title's allocation as pointers and lengths — undefined behavior before reachable() could weigh in (#428).

A SOCKET_ADDRESS_LIST carries no size the count could be checked against, so the count is the title's word alone. More candidates than any title offers (MAX_CONNECT_LIST, 64) are now refused with WSAEINVAL and a FALSE return — the same fail-closed posture as the rest of this module — while honest lists reach the host unchanged and the vetting loop is untouched.

The new test builds a one-entry list whose count claims i32::MAX and asserts the call returns 0 with WSAEINVAL set, refusing before the entries are walked.

Fixes #428.

Verification:

  • cargo clippy --target x86_64-pc-windows-msvc --workspace --all-targets --locked -- -D warnings (clang-cl 23.1.5, cross-checked from Linux) passes on default features and on --all-features; this compiles the new test, which then runs in this repo's Windows CI.
  • This module is #[cfg(windows)]-gated, so the Linux build is untouched by construction; main's pre-existing non-Windows test-compile gaps are outside this change and covered by #449.

No formatting-only churn: one const with its rationale, a four-line guard, one test.


Disclosure: written with AI assistance (GLM via OpenCode) — the fix, test, and cross-verification were drafted and run with the tool, following the report in #428. Reviewed and understood by the human submitting it.

**@⁠iloveslopware** on GitHub · 2026-11-25 01:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/476) `iloveslopware:wsaconnectbylist-count` → `main` · +42 −0 · 1 files · 1 commits · closed without merging `WSAConnectByList` turned `iAddressCount` into a `&[SocketAddress]` of that length before any address was vetted, so a list holding one 16-byte entry with `iAddressCount = 0x7FFFFFFF` produced a ~34 GB slice and read far past the title's allocation as pointers and lengths — undefined behavior before `reachable()` could weigh in (#428). A `SOCKET_ADDRESS_LIST` carries no size the count could be checked against, so the count is the title's word alone. More candidates than any title offers (`MAX_CONNECT_LIST`, 64) are now refused with `WSAEINVAL` and a `FALSE` return — the same fail-closed posture as the rest of this module — while honest lists reach the host unchanged and the vetting loop is untouched. The new test builds a one-entry list whose count claims `i32::MAX` and asserts the call returns 0 with `WSAEINVAL` set, refusing before the entries are walked. Fixes #428. Verification: - `cargo clippy --target x86_64-pc-windows-msvc --workspace --all-targets --locked -- -D warnings` (clang-cl 23.1.5, cross-checked from Linux) passes on default features and on `--all-features`; this compiles the new test, which then runs in this repo's Windows CI. - This module is `#[cfg(windows)]`-gated, so the Linux build is untouched by construction; `main`'s pre-existing non-Windows test-compile gaps are outside this change and covered by #449. No formatting-only churn: one const with its rationale, a four-line guard, one test. --- Disclosure: written with AI assistance (GLM via OpenCode) — the fix, test, and cross-verification were drafted and run with the tool, following the report in #428. Reviewed and understood by the human submitting it.
The count became a &[SocketAddress] of that length before any address
was vetted, so one real 16-byte entry with iAddressCount = 0x7FFFFFFF
made a ~34 GB slice and read past the allocation as pointers and
lengths. A SOCKET_ADDRESS_LIST carries no size to check the count
against, so more candidates than any title offers (64) are now refused
with WSAEINVAL instead of walked: the call fails closed like every
other vetted path in this module, and honest lists still reach the
host unchanged.

Fixes #428.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:12 +00:00
github-bot closed this pull request 2026-11-26 03:44:12 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:41 UTC · original

Is this a duplicate of #466?

Both address #428 by rejecting oversized WSAConnectByList counts.

This is an automated message. If you believe it is incorrect, please reply with the relevant technical differences.

**@⁠kaayzouee** on GitHub · 2026-11-25 01:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/476#issuecomment-7149840594) Is this a duplicate of #466? Both address #428 by rejecting oversized WSAConnectByList counts. This is an automated message. If you believe it is incorrect, please reply with the relevant technical differences.
Author
Owner

@⁠iloveslopware on GitHub · 2026-11-25 01:44 UTC · original

Yes — #466 was opened five minutes before this one and covers the same defect more completely: it also refuses a negative iAddressCount (which this change left falling to 0 and forwarding the list to the host unvetted), and it reads the entries one at a time with read_unaligned rather than forming a &[SocketAddress]. Its tests cover more ground too, including the host-connect path on real hardware. The cap (64) and the failure mode (WSAEINVAL + FALSE) are identical, so there is nothing here that #466 lacks — closing in its favor.

**@⁠iloveslopware** on GitHub · 2026-11-25 01:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/476#issuecomment-7149903316) Yes — #466 was opened five minutes before this one and covers the same defect more completely: it also refuses a *negative* `iAddressCount` (which this change left falling to 0 and forwarding the list to the host unvetted), and it reads the entries one at a time with `read_unaligned` rather than forming a `&[SocketAddress]`. Its tests cover more ground too, including the host-connect path on real hardware. The cap (64) and the failure mode (`WSAEINVAL` + `FALSE`) are identical, so there is nothing here that #466 lacks — closing in its favor.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.