Repository navigation
Description
Note: Both the bug and the following is written by Claude Opus 5.5, but I DID review everything and do think what it found is valid.
Bug: Freedom UDP is no longer full-cone since #6754
Affected: main since 8267cf95 ("Transport: Refactor to be based on Finalmask's dialer & listener", #6754, 2026-09-21). Not in any release; v26.9.9 is fine.
Summary
Since #6754 the freedom outbound sends every UDP packet of a flow to the first destination, and replies no longer carry their real source address. This breaks full-cone NAT behind freedom for XUDP, Mux UDP, the TUN and SOCKS inbounds, the WireGuard inbound, and anything else that sets a destination on each packet.
Cause
- The UDP transport dialer now always goes through
FinalMask.DialUDP(transport/internet/udp/dialer.go:15-16), becauseToMemoryStreamConfigalways createsFinalMask(transport/internet/memory_settings.go:100). The connection it returns is a*finalmask.PacketConnWrapper. - Freedom only turns on its per-packet
PacketReader/PacketWriterfor*internet.PacketConnWrapper(proxy/freedom/freedom.go:470,:545). Every UDP flow therefore falls back tobuf.SequentialWriter/buf.PacketReader, and those:- write with
Write(), which goes to the address the flow was dialed to, ignoring each packet's destination (b.UDP); - read with
ReadFrom()and throw away the sender, sob.UDPis nil on replies; - skip the per-packet
finalRuleschecks and the domain resolution cache.
- write with
Before #6754, the UDP dialer returned *internet.PacketConnWrapper, and even wrapped masked connections back into that type.
Impact
- Packets addressed to a second peer (B) on the same flow go to the first peer (A).
- Replies look as if they came from the original target. A packet from any other peer is accepted and passed on as if it came from the target.
- Per-packet
finalRulesare skipped: the default private-IP block for VLESS/VMess/Trojan/WireGuard inbounds is only checked against the first destination.
Reproduction
Start freedom from a normal JSON config and run one UDP flow: packet 1 goes to echo server A (the flow target), and packet 2 is addressed to echo server B.
| v26.9.9 | main (e5e85ca9) |
|
|---|---|---|
| Packet 2 received by | B | A |
| Reply sources | A, B | none |
| Unsolicited packet source | real sender | none |
The same failure shows up when the traffic comes in through a WireGuard inbound. There, replies are labelled as coming from the original target A.
How to check
Use the tests on branch tests/udp-fullcone-wireguard-races (https://github.com/LagPixelLOL/Xray-core). No root is needed.
./run.sh /path/to/Xray-core v26.9.9 mainOn main, these tests fail: TestFreedomUDPPerPacketDestination, TestFreedomUDPUnsolicitedReplySource, TestWireGuardUDPPerPacketDestination and TestWireGuardUDPUnsolicitedReplySource. TestFreedomUDPDialerProxyUnchanged passes on both.
Activity
Xray-core: Move PacketConnWrapper to common/net (XTLS#6854)
Xray-core: Move PacketConnWrapper to common/net (#6854)
Xray-core: Move PacketConnWrapper to common/net (#6854)
Xray-core: Move PacketConnWrapper to common/net (#6854)