[HLE/net] WSAConnectByList builds an unbounded slice from a title-supplied count #428

Open
opened 2026-11-26 03:43:06 +00:00 by github-bot · 0 comments
Owner

@⁠joseschesben-collab on GitHub · 2026-11-25 00:42 UTC · original

Severity: medium (unbounded read / immediate UB in the emulator at an HLE boundary)
File: crates/victory-hle/src/modules/net.rs:310-321 (especially 313-315)
HEAD: a803c87c48078e57b296e06e08146d7ceca44530

Proof

WSAConnectByList reads iAddressCount from the title's SOCKET_ADDRESS_LIST. The conversion already treats the count as untrusted:

let count = usize::try_from(list.cast::<i32>().read()).unwrap_or(0);
std::slice::from_raw_parts(list.add(8).cast::<SocketAddress>(), count)

but count is then used directly as the slice length, with no upper bound and no check against the bytes actually present in the structure. SocketAddress is 16 bytes on x64 (*const u8 + i32 + padding).

A single connect-by-list call with one real entry (16 bytes of payload) and iAddressCount = 0x7FFFFFFF creates a slice of roughly 34 GB starting at that 16-byte buffer. entries.iter() at lines 316-319 reads out of the allocation as SocketAddress values — undefined behavior before reachable() even gets a chance to reject the address.

Expected vs actual

  • Expected: the count is validated like other untrusted arguments; the shim rejects the call (WSAEINVAL/WSAENETUNREACH) or examines only the entries actually present.
  • Actual: the count becomes a &[SocketAddress] of arbitrary length; arbitrary memory is deserialized as address pointers and lengths.

Suggested fix

Put a ceiling on the count (e.g. 64) and/or avoid constructing the slice: walk the entries with checked_add/checked_mul inside an explicit bound, read_unaligned() each SocketAddress, and validate addr/len before reading — the same way socket_addr() already validates len.

Duplicates

None of the 422 existing issues mention net.rs, Winsock, WSA*, sockets or connect-by-list. The closest by theme is #161 (HLE last-error behavior), which is unrelated.

**@⁠joseschesben-collab** on GitHub · 2026-11-25 00:42 UTC · [original](https://github.com/fxceless/victory-fork/issues/428) **Severity:** medium (unbounded read / immediate UB in the emulator at an HLE boundary) **File:** `crates/victory-hle/src/modules/net.rs:310-321` (especially 313-315) **HEAD:** `a803c87c48078e57b296e06e08146d7ceca44530` ## Proof `WSAConnectByList` reads `iAddressCount` from the title's `SOCKET_ADDRESS_LIST`. The conversion already treats the count as untrusted: ```rust let count = usize::try_from(list.cast::<i32>().read()).unwrap_or(0); std::slice::from_raw_parts(list.add(8).cast::<SocketAddress>(), count) ``` but `count` is then used directly as the slice length, with no upper bound and no check against the bytes actually present in the structure. `SocketAddress` is 16 bytes on x64 (`*const u8` + `i32` + padding). A single `connect-by-list` call with one real entry (16 bytes of payload) and `iAddressCount = 0x7FFFFFFF` creates a slice of roughly 34 GB starting at that 16-byte buffer. `entries.iter()` at lines 316-319 reads out of the allocation as `SocketAddress` values — undefined behavior before `reachable()` even gets a chance to reject the address. ## Expected vs actual - Expected: the count is validated like other untrusted arguments; the shim rejects the call (`WSAEINVAL`/`WSAENETUNREACH`) or examines only the entries actually present. - Actual: the count becomes a `&[SocketAddress]` of arbitrary length; arbitrary memory is deserialized as address pointers and lengths. ## Suggested fix Put a ceiling on the count (e.g. 64) and/or avoid constructing the slice: walk the entries with `checked_add`/`checked_mul` inside an explicit bound, `read_unaligned()` each `SocketAddress`, and validate `addr`/`len` before reading — the same way `socket_addr()` already validates `len`. ## Duplicates None of the 422 existing issues mention `net.rs`, Winsock, `WSA*`, sockets or connect-by-list. The closest by theme is #161 (HLE last-error behavior), which is unrelated.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:06 +00:00
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/fxceless--victory-fork#428
No description provided.