Skip to content

UDP datagram from a socket that closes within a few milliseconds bypasses a named-application rule #193

Open

Description

@wiresock

Summary

A UDP datagram sent by an application that a rule proxies leaves the adapter directly, from the computer's real address, when the application closes the socket within a few milliseconds of sending. The remote server then answers directly as well.

Found while validating #192 (ICMP errors about proxied UDP replies). It is not caused by #190 or #192: the owner-resolution path they leave untouched decides this.

What was observed

Engine built from d26dbba, running as the elevated service; Windows 11 x64; Windows Packet Filter 3.6.2.1; capture at the physical NIC with pktmon. One rule with "appNames": ["python"], TCP and UDP, DNS Direct. The test application sends one STUN binding request per fresh socket to a public STUN server over IPv4 and closes the socket after a set delay. 12 datagrams per delay:

Socket closed after Sent directly to the server Sent through the proxy
0 ms 12 0
2 ms 9 3
10 ms 0 12
30 ms 0 12

With the socket kept open until the reply, every datagram is proxied (the STUN mapped address is the proxy's). IPv6 showed the same at 0 ms: 30 of 30 datagrams appeared on the adapter addressed to the server.

Reproduce

import os, socket, struct, time
SERVER = ("74.125.250.129", 19302)          # any UDP service that answers
for _ in range(12):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.sendto(struct.pack(">HHI", 1, 0, 0x2112A442) + os.urandom(12), SERVER)
    s.close()                               # close at once
    time.sleep(0.3)

Run it with python.exe matched by a rule that proxies UDP, and capture on the physical adapter with the filter udp && ip.dst == <server>. The datagrams are there; with a time.sleep(0.05) before close() they are not.

Likely cause (from reading the code, not instrumented)

The first datagram from a new local port has no cached owner, so process_udp_packet() returns std::nullopt and the packet is queued for the deferred-resolve thread, which refreshes the process tables and looks the endpoint up again. By then the socket is closed and the endpoint is no longer in the UDP table, so the packet is attributed to the unresolved owner. A rule that names an application does not match the unresolved owner, and the packet is passed.

If that is right, a catch-all rule ("appNames": [""]) would still proxy such a datagram in the elevated service, because the unresolved owner matches the catch-all there. I did not test that.

Impact

  • The destination sees the computer's real address for that datagram, and answers it outside the proxy.
  • It only affects sockets that live for a few milliseconds: fire-and-forget senders such as some telemetry, syslog or statsd-style clients, or a tool that sends one datagram and exits. An application that waits for a reply is not affected.
  • TCP was not tested. A TCP connection cannot close before its SYN is processed in the same way, so it is probably not affected.

Notes

  • docs/configuration.md describes the fail-direct behaviour for unresolved owners only for the limited (non-administrator) mode. This case happens in the elevated service.
  • Validation step 16 in docs/gui.md now tells the tester to keep the socket open for about 50 ms for this reason (5fddaca).

Activity

  1. added
    bug
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions