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

Open
github-bot wants to merge 1 commit from github-bot/gh-2860 into main AGit
Owner

@⁠miatson on GitHub · 2026-11-25 22:36 UTC · original
miatson:net-iphlpapi-traffic-loopback-only → main · +460 −1 · 2 files · 1 commits · open

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.

**@⁠miatson** on GitHub · 2026-11-25 22:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2860) `miatson:net-iphlpapi-traffic-loopback-only` → `main` · +460 −1 · 2 files · 1 commits · open ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:08 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:24 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-26 04:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2860#issuecomment-7182562409) <!-- 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2860/head:github-bot/gh-2860'
git switch 'github-bot/gh-2860'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2860'
git switch 'github-bot/gh-2860'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2860'
git switch 'github-bot/gh-2860'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2860'
git switch 'main'
git merge --squash 'github-bot/gh-2860'
git switch 'main'
git merge --ff-only 'github-bot/gh-2860'
git switch 'main'
git merge 'github-bot/gh-2860'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!2860
No description provided.