Net: the IP helper's echo requests and address resolution reach loopback only #2858

Open
miatson wants to merge 1 commit from upstream-pr/2860 into main
miatson commented 2026-11-25 22:36:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by miatson on 2026-11-25T22:36:40Z.


Problem

net.rs keeps the title to loopback ("a console without a network cable"), but only
for the ways out of Winsock and WinHTTP. iphlpapi.dll is in the default HostPolicy
and passes through whole, and it sends packets of its own that never go through Winsock:

  • ICMP echo requests (IcmpSendEcho, IcmpSendEcho2, IcmpSendEcho2Ex, Icmp6SendEcho2),
    to any address, with any payload;
  • ARP and neighbor solicitations (SendARP, ResolveIpNetEntry2, ResolveNeighbor).

This is the kind of path #510 kept rpcrt4.dll out of the host policy for: network
traffic modules::net never sees.

Reproduced on main (13f91ca): the title's iphlpapi.dll!IcmpSendEcho import resolves
to the host's own function (Provenance::Host), and an echo request through it to the
machine's own LAN address is answered.

Change

net.rs now also serves iphlpapi.dll, for those seven calls only. Each one checks the
destination with the existing loopback() rule: loopback goes to the host's function as
before; anything else fails before a packet is sent, as with no network:

  • echo requests return 0 with IP_DEST_NET_UNREACHABLE (also the async forms: the last
    error isn't ERROR_IO_PENDING, so nothing waits on the event or APC);
  • SendARP, ResolveIpNetEntry2 and ResolveNeighbor return ERROR_BAD_NET_NAME, what an
    unanswered resolution reports. Null arguments are left for the host to refuse.

Everything else in iphlpapi.dll (adapters, routes, notifications, IcmpCreateFile, ...)
is still the host's. Blocked destinations are logged once, as the other refusals are.

Tests

  • ip_helper_traffic_is_vetted_here: the seven calls resolve to ours (Provenance::Hle)
    through HleResolver; GetAdaptersAddresses, IcmpCreateFile, IcmpCloseHandle stay the host's.
  • a_title_echo_request_reaches_loopback_only: end to end, through the functions as the
    title binds them. 127.0.0.1 answers; the machine's own LAN address doesn't.
  • ip_helper_arp_stays_on_the_machine, ip_helper_neighbor_resolution_stays_on_the_machine:
    resolving the machine's own LAN address (which the host resolves) is refused.
  • ip_helper_ipv6_echo_reaches_loopback_only: [::1] answers; the machine's own IPv6 address
    is refused when it has one.

The tests aim at the machine's own addresses, which the host would answer, so they can't
pass for the wrong reason. On main, the first two fail (Some(Host); the echo request is
answered). As a negative control, with the loopback check disabled, the echo, ARP and
neighbor tests fail (answered / resolved with NO_ERROR) and pass with it. The tests that
need a network skip without one; on the test machine there was no IPv6 route, so only the
IPv6 loopback half ran.

cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings is clean,
rustfmt --check is clean for both files, and cargo test --workspace --locked passes
(784 passed, 0 failed).

Tested on

  • Windows 11 Pro 26H2 (build 26300)
  • AMD Radeon RX 7900 XT, driver 32.0.32015.7029
  • AMD Ryzen 7 9700X, 32 GB RAM
  • rustc 1.98.1 (the pinned toolchain)
  • Based on main at 13f91ca

Notes

  • Not tested in game (no game data); the title isn't known to send pings, so this closes
    a way out rather than changing observed behavior.
  • Other allowed DLLs that can reach the network on their own (COM via ole32, certificate
    fetching in crypt32) are out of scope here.

Written with the help of Claude Code.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6615169457 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2860). Originally posted by [miatson](https://github.com/miatson) on 2026-11-25T22:36:40Z. --- ## Problem `net.rs` keeps the title to loopback ("a console without a network cable"), but only for the ways out of Winsock and WinHTTP. `iphlpapi.dll` is in the default `HostPolicy` and passes through whole, and it sends packets of its own that never go through Winsock: - ICMP echo requests (`IcmpSendEcho`, `IcmpSendEcho2`, `IcmpSendEcho2Ex`, `Icmp6SendEcho2`), to any address, with any payload; - ARP and neighbor solicitations (`SendARP`, `ResolveIpNetEntry2`, `ResolveNeighbor`). This is the kind of path #510 kept `rpcrt4.dll` out of the host policy for: network traffic `modules::net` never sees. Reproduced on `main` (13f91ca): the title's `iphlpapi.dll!IcmpSendEcho` import resolves to the host's own function (`Provenance::Host`), and an echo request through it to the machine's own LAN address is answered. ## Change `net.rs` now also serves `iphlpapi.dll`, for those seven calls only. Each one checks the destination with the existing `loopback()` rule: loopback goes to the host's function as before; anything else fails before a packet is sent, as with no network: - echo requests return 0 with `IP_DEST_NET_UNREACHABLE` (also the async forms: the last error isn't `ERROR_IO_PENDING`, so nothing waits on the event or APC); - `SendARP`, `ResolveIpNetEntry2` and `ResolveNeighbor` return `ERROR_BAD_NET_NAME`, what an unanswered resolution reports. Null arguments are left for the host to refuse. Everything else in `iphlpapi.dll` (adapters, routes, notifications, `IcmpCreateFile`, ...) is still the host's. Blocked destinations are logged once, as the other refusals are. ## Tests - `ip_helper_traffic_is_vetted_here`: the seven calls resolve to ours (`Provenance::Hle`) through `HleResolver`; `GetAdaptersAddresses`, `IcmpCreateFile`, `IcmpCloseHandle` stay the host's. - `a_title_echo_request_reaches_loopback_only`: end to end, through the functions as the title binds them. 127.0.0.1 answers; the machine's own LAN address doesn't. - `ip_helper_arp_stays_on_the_machine`, `ip_helper_neighbor_resolution_stays_on_the_machine`: resolving the machine's own LAN address (which the host resolves) is refused. - `ip_helper_ipv6_echo_reaches_loopback_only`: `[::1]` answers; the machine's own IPv6 address is refused when it has one. The tests aim at the machine's own addresses, which the host would answer, so they can't pass for the wrong reason. On `main`, the first two fail (`Some(Host)`; the echo request is answered). As a negative control, with the loopback check disabled, the echo, ARP and neighbor tests fail (answered / resolved with `NO_ERROR`) and pass with it. The tests that need a network skip without one; on the test machine there was no IPv6 route, so only the IPv6 loopback half ran. `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` is clean, `rustfmt --check` is clean for both files, and `cargo test --workspace --locked` passes (784 passed, 0 failed). ## Tested on - Windows 11 Pro 26H2 (build 26300) - AMD Radeon RX 7900 XT, driver 32.0.32015.7029 - AMD Ryzen 7 9700X, 32 GB RAM - rustc 1.98.1 (the pinned toolchain) - Based on `main` at 13f91ca ## Notes - Not tested in game (no game data); the title isn't known to send pings, so this closes a way out rather than changing observed behavior. - Other allowed DLLs that can reach the network on their own (COM via `ole32`, certificate fetching in `crypt32`) are out of scope here. Written with the help of Claude Code.
kotekompotek commented 2026-11-25 23:05:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:52:02Z.

Review: COMMENTED


Policy-consistent: iphlpapi traffic bypasses Winsock, so it needs its own loopback gate — failing non-loopback echo with IP_DEST_NET_UNREACHABLE (11002) and resolution with ERROR_BAD_NET_NAME (67) matches what the title would see on a genuinely unreachable network, and the rest of the DLL stays host-backed. Fail-before-send is the right order. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066078447 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2860#pullrequestreview-6066078447). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:52:02Z. **Review:** COMMENTED --- Policy-consistent: iphlpapi traffic bypasses Winsock, so it needs its own loopback gate — failing non-loopback echo with IP_DEST_NET_UNREACHABLE (11002) and resolution with ERROR_BAD_NET_NAME (67) matches what the title would see on a genuinely unreachable network, and the rest of the DLL stays host-backed. Fail-before-send is the right order. LGTM.
fuzeofficlal commented 2026-11-26 00:02:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:44:16Z.

Review: COMMENTED


Verified head e950b059 cleanly merged onto origin/main (63bcca43) on Windows 11 x64.

Code & Isolation Review

  • Intercepts all 7 iphlpapi.dll off-box echo / neighbor-resolution entry points (IcmpSendEcho, IcmpSendEcho2, IcmpSendEcho2Ex, Icmp6SendEcho2, SendARP, ResolveIpNetEntry2, ResolveNeighbor) while keeping non-transmitting host queries (GetAdaptersAddresses, IcmpCreateFile, IcmpCloseHandle) on HostPolicy.
  • ip.to_canonical().is_loopback() properly allows IPv4 127.0.0.0/8, IPv6 ::1, and IPv4-mapped IPv6 ::ffff:127.0.0.1 while blocking external targets.
  • Refusal codes and pointer handling are solid: ICMP refusals set IP_DEST_NET_UNREACHABLE (11002) and return 0 synchronously (never ERROR_IO_PENDING), ARP/neighbor refusals set and return ERROR_BAD_NET_NAME (67), and any_socket_addr dispatches on the u16 address family before reading so a 16-byte SOCKADDR_IN is never over-read as SOCKADDR_IN6.

Local Verification

  • cargo test --locked -p victory-hle: 157/157 unit tests passed (including all 5 new ip_helper_* / echo / arp / neighbor tests), plus fidelityfx (1/1) and no_dll_planting (1/1).
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (191 files ok): clean.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066566110 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2860#pullrequestreview-6066566110). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:44:16Z. **Review:** COMMENTED --- Verified head `e950b059` cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64. ### Code & Isolation Review - Intercepts all 7 `iphlpapi.dll` off-box echo / neighbor-resolution entry points (`IcmpSendEcho`, `IcmpSendEcho2`, `IcmpSendEcho2Ex`, `Icmp6SendEcho2`, `SendARP`, `ResolveIpNetEntry2`, `ResolveNeighbor`) while keeping non-transmitting host queries (`GetAdaptersAddresses`, `IcmpCreateFile`, `IcmpCloseHandle`) on `HostPolicy`. - `ip.to_canonical().is_loopback()` properly allows IPv4 `127.0.0.0/8`, IPv6 `::1`, and IPv4-mapped IPv6 `::ffff:127.0.0.1` while blocking external targets. - Refusal codes and pointer handling are solid: ICMP refusals set `IP_DEST_NET_UNREACHABLE` (`11002`) and return `0` synchronously (never `ERROR_IO_PENDING`), ARP/neighbor refusals set and return `ERROR_BAD_NET_NAME` (`67`), and `any_socket_addr` dispatches on the `u16` address family before reading so a 16-byte `SOCKADDR_IN` is never over-read as `SOCKADDR_IN6`. ### Local Verification - `cargo test --locked -p victory-hle`: **157/157** unit tests passed (including all 5 new `ip_helper_*` / `echo` / `arp` / `neighbor` tests), plus `fidelityfx` (1/1) and `no_dll_planting` (1/1). - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo xtask policy` (`191 files ok`): clean. Looks clean and ready to merge.
Marvisak commented 2026-11-26 05:04:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:24:08Z.


Automated triage for the maintainers.

Needs work. Needs the maintainer's decision, since it touches the offline net module (it tightens it) and its tests send ICMP echo to the machine's own address. Routing IcmpSendEcho*, Icmp6SendEcho2, SendARP, ResolveIpNetEntry2 and ResolveNeighbor through the existing loopback() check closes a real way off the machine. One problem: adding "iphlpapi.dll" to the net module's dlls serves every export of that module for iphlpapi.dll, including the ws2_32 ordinals #2, #4 and #20, so an iphlpapi.dll import by ordinal would bind to bind, connect or sendto. Please register the IP helper exports in their own HleModule that serves only iphlpapi.dll.

CI: not run yet on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182562409 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2860#issuecomment-7182562409). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:24:08Z. --- <!-- victory-triage v1 head=e950b0598f71eda170e8c5b1a82ee2d94d03384d verdict=needs-work at=2026-11-26T04:24:01Z --> Automated triage for the maintainers. **Needs work.** Needs the maintainer's decision, since it touches the offline `net` module (it tightens it) and its tests send ICMP echo to the machine's own address. Routing `IcmpSendEcho*`, `Icmp6SendEcho2`, `SendARP`, `ResolveIpNetEntry2` and `ResolveNeighbor` through the existing `loopback()` check closes a real way off the machine. One problem: adding `"iphlpapi.dll"` to the `net` module's `dlls` serves every export of that module for `iphlpapi.dll`, including the ws2_32 ordinals `#2`, `#4` and `#20`, so an `iphlpapi.dll` import by ordinal would bind to `bind`, `connect` or `sendto`. Please register the IP helper exports in their own `HleModule` that serves only `iphlpapi.dll`. CI: not run yet on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2860:upstream-pr/2860'
git switch 'upstream-pr/2860'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2860'
git switch 'upstream-pr/2860'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2860'
git switch 'upstream-pr/2860'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2860'
git switch 'main'
git merge --squash 'upstream-pr/2860'
git switch 'main'
git merge --ff-only 'upstream-pr/2860'
git switch 'main'
git merge 'upstream-pr/2860'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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!2858
No description provided.