Skip to content

Drop ICMP errors that quote a proxied UDP reply - #192

Merged
wiresock merged 2 commits into
claude/proxifyre-dns-routing-f94k1ofrom
claude/ecstatic-mccarthy-8tehu6
Nov 14, 2026
Merged

wiresock merged 2 commits into
claude/proxifyre-dns-routing-f94k1ofrom
claude/ecstatic-mccarthy-8tehu6

Conversation

@wiresock

@wiresock wiresock commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #190 (based on its branch); one commit, d26dbba. It extends 216bcf6 from DNS answers to all application UDP that a rule proxies.

Problem

A reply on a proxied UDP flow reaches the application as if it came from the remote peer: socks5_udp_local_redirect restores the peer named in the SOCKS5 UDP header. If the application's socket has already closed when the reply arrives, Windows answers with an ICMP "port unreachable" (ICMPv6 "destination unreachable") error addressed to that peer. The error leaves the adapter directly, from the computer's real address, and quotes the reply. So the peer learns the client's real IP and sees the reply contents, bypassing the proxy. 216bcf6 fixed this for DNS answers in Proxy mode only; on main and on #190, application UDP still behaves this way.

Change

  • Drop rule. An outbound ICMP or ICMPv6 error is dropped when the UDP datagram it quotes was addressed to a client port with an active entry (last 15 minutes) in that family's UDP redirect. This applies in either DNS mode.
    • The redirect is keyed by client port only and does not record the remote endpoints of replies. A datagram reaching that port came either through the proxy (the leak) or directly from a sender that already knows the address. Matching on the port is therefore leak-safe, and the only cost is a lost error report to such a direct sender.
    • Ping, neighbor discovery, quoted TCP, quotes cut before the destination port, and errors about unproxied ports are passed.
    • The first drop per run is logged at info level with the port; later drops are counted in the throttled debug report.
  • Parsing (dns_routing_policy.h). icmpv4_error_quote() / icmpv6_error_quote() return both quoted ports; the existing source-port helpers are wrappers over them. decide_icmp_error(mode, quote, is_redirected_client_port) returns pass, drop_dns_answer or drop_proxied_udp_reply. It calls the lookup, and so takes the redirect's lock, only for a quoted UDP datagram with both ports, after the DNS check.
  • Redirect. socks5_udp_local_redirect::is_active_endpoint(); the 15-minute timeout is now a named constant.
  • ICMP filter. It is needed outside DNS Proxy mode: for IPv4, the router's ICMP PASS filter would otherwise pass the error in the driver.
    • plan_icmp_error_filters(mode, ipv4_udp, ipv6_udp) asks for the outbound REDIRECT filter, at the front of the table, for each family with a UDP listener and for both families in DNS Proxy mode.
    • install_icmp_error_filters() runs on start(), and from add_socks5_proxy() when a UDP listener is added to a running router. It only adds missing filters, so there is no window without one.
    • A filter that cannot be installed fails start(), or rejects the proxy being added.

Tests

  • Portable suite: 118 tests (113 before), also under ASan/UBSan. They cover:
    • quote parsing, both ports and a quote cut between them;
    • the decision in both modes, and that the redirect lookup is consulted only for quoted UDP;
    • the filter plan;
    • an end-to-end test per family through the real socks5_udp_local_redirect: an application datagram is redirected, the listener's reply is translated, and the stack's error about the translated reply is dropped, while ping and errors about unredirected ports pass.
  • CI on Windows. A manually started main.yml run built x86, x64 and ARM64 Release successfully, and the managed tests passed: https://github.com/wiresock/proxifyre/actions/runs/43570903168. It ran on 4d98555, which has the same tree as d26dbba (only the commit metadata changed). The router class itself is not covered by an automated test.

Windows validation required before merge

Not yet run on a machine with the driver. Step 16 of "DNS routing manual validation" in docs/gui.md covers it:

  • With Direct DNS and a rule that proxies UDP, send a datagram to a server that answers after a delay (IPv4 and IPv6) and close the socket before the reply arrives. Capture at the physical NIC (pktmon or Wireshark icmp.type == 3 || icmpv6.type == 1): no error addressed to the server leaves the adapter, and the log has one "Dropped an ICMP error about a proxied UDP reply" line.
  • The same with the rule disabled: the error does leave the adapter, which shows the test provokes it.
  • ping and ping -6 to the server still work; repeat in Proxy mode.

Validation status (2026-11-14). Run on Windows 11 x64 with Windows Packet Filter 3.6.2.1 and a live SOCKS5-over-TLS server, capturing at the physical NIC with pktmon, against d26dbba. All three items pass:

  • With the rule: 60 datagrams (30 per family) were all proxied, and no ICMP type 3 or ICMPv6 type 1 message left the adapter; the log has one "Dropped an ICMP error about a proxied UDP reply" line naming a port the test client used.
  • Without the rule, 10 errors left the adapter. The test machine has no native IPv6, so the IPv6 control used the base commit 216bcf6 with the rule enabled: 12 IPv4 and 12 IPv6 errors quoting proxied replies left the adapter.
  • ping is answered in both DNS modes. ping -6 echo requests leave the adapter in both modes but get no reply, for lack of IPv6 connectivity.

The sockets were closed 60 ms after sending. A socket closed at once is gone before its datagram can be attributed to the application, so the datagram leaves directly (12 of 12 at 0 ms, none at 10 ms or more) and the error is then about a direct reply; step 16 should say so.

Docs

  • docs/configuration.md: a third rule under "Local listener replies and TCP close handling", a paragraph on the ICMP filter, and a link from the DNS ICMP paragraph.
  • docs/gui.md: validation step 16; later steps renumbered.

A reply on a UDP flow that a rule proxies reaches the application as if it
came from the remote peer: socks5_udp_local_redirect restores the peer named
in the SOCKS5 UDP header. If the application's socket has closed when the
reply arrives, Windows reports it with an ICMP "port unreachable" (ICMPv6
"destination unreachable") error addressed to that peer. The error leaves the
adapter directly, from the computer's own address, and quotes the reply, so
the peer learns the real address and sees the reply contents. The previous
commit handled this for DNS answers in Proxy mode only.

- An outbound ICMP or ICMPv6 error is dropped when the UDP datagram it quotes
  was addressed to a client port with an active entry in the UDP redirect of
  that family. This applies in either DNS mode. The redirect is keyed by
  client port, so a datagram that port received directly is matched too; that
  sender already knows the address and only loses the error report. Ping,
  neighbor discovery, TCP quotes and errors about unproxied ports are passed.
  The first drop per run is logged at info level with the port; later drops
  are counted at debug level.
- The quoted-header parsing in dns_routing_policy.h now returns both quoted
  ports (icmpv4_error_quote(), icmpv6_error_quote()). The source-port helpers
  are kept as wrappers. decide_icmp_error() takes the quote and a lookup of
  redirected client ports, and only calls the lookup (and so takes the
  redirect's lock) for a quoted UDP datagram with both ports.
- socks5_udp_local_redirect::is_active_endpoint() reports whether a client
  port has an entry that has not timed out (15 minutes, now a named constant).
- The REDIRECT filter for outbound ICMP is now needed outside DNS Proxy mode:
  for IPv4, the router's ICMP PASS filter would otherwise pass the error in
  the driver. plan_icmp_error_filters() installs it per address family when
  that family has a UDP listener, and for both families in DNS Proxy mode.
  install_icmp_error_filters() runs on start() and also when
  add_socks5_proxy() adds a UDP listener to a running router. It only adds
  missing filters, so there is never a moment without one.
- Tests: quote parsing (both ports, a quote cut between them), the decision
  in both modes, the lookup only being consulted for quoted UDP, and the
  filter plan. The portable suite also drives the real redirect: an IPv4 and
  an IPv6 application flow is redirected, the listener's reply is translated,
  and the stack's error about the translated reply is dropped, while ping and
  errors about unredirected ports pass.
- Docs: the behaviour and the filter in configuration.md, and a Windows
  validation step with pktmon/Wireshark in gui.md.
@wiresock
wiresock force-pushed the claude/ecstatic-mccarthy-8tehu6 branch from 4d98555 to d26dbba Compare November 14, 2026 07:41
Step 16 told the tester to close the socket before the reply arrives. A
socket closed at once is gone before its datagram can be attributed to the
application, so the datagram is sent directly, the server answers directly,
and the ICMP error about that direct reply is passed, which looks like the
drop not working. Measured on Windows with 12 datagrams per delay: closed
after 0 ms, all 12 went out directly; after 2 ms, 9 did; after 10 ms and
30 ms, none.

The step now says to keep the socket open for about 50 ms, to use a server
that delays its reply when the SOCKS5 server answers faster than that, and
to confirm in the capture that no datagram went to the server directly. A
STUN binding request is added to the example datagrams.
@wiresock
wiresock merged commit e0493f9 into claude/proxifyre-dns-routing-f94k1o Nov 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant