Skip to content

QUIC sniffer: Handle zero-filled datagram tails - #6882

Merged
RPRX merged 4 commits into
XTLS:mainfrom
Barsoomx:fix/quic-zero-padded-datagrams
Oct 5, 2026
Merged

RPRX merged 4 commits into
XTLS:mainfrom
Barsoomx:fix/quic-zero-padded-datagrams

Conversation

@Barsoomx

@Barsoomx Barsoomx commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

When cached UDP datagrams are concatenated, zero bytes after a packet's declared length are treated as another QUIC header. SniffQUIC then returns not initial packet before a later Initial can complete the fragmented ClientHello. This can leave IP-addressed UDP traffic without an SNI for domain routing.

Skip zero-filled tails after the checked packet boundary. The regression fixture contains two encrypted Initial datagrams: the first needs more data, and their concatenation recovers the expected SNI. The first 1252-byte datagram contains a 996-byte packet followed by 256 zero bytes.

Observed with Firefox 157 HTTP/3 over Hysteria2. A patched build also passes the same browser routing check. This is a follow-up to #4642.

Validation on current main:

  • The new regression fails before the parser change and passes after it.
  • go test ./common/protocol/quic -count=1
  • go run ./infra/vformat/main.go -mode check -pwd ./

The fixture contains UDP payloads only, with no IP headers or tunnel credentials.

@Fangliding Fangliding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无论真实存在与否 这的确是符合RFC的报文

patterniha pushed a commit to patterniha/Xray-core that referenced this pull request Oct 3, 2026
Early merge of XTLS#6882 (PR head 1c00a9c), squashed, ahead of
it landing upstream: XTLS#6882

Co-authored-by: 风扇滑翔翼 <[email protected]>
@RPRX
RPRX merged commit 5121c28 into XTLS:main Oct 5, 2026
olivezane added a commit to olivezane/Xray-core-ai that referenced this pull request Oct 6, 2026
7 upstream commits: WireGuard kernelTun IPv6 table index fix (XTLS#6881),
WireGuard idle-flow memory and ICMP pong (XTLS#6856, XTLS#6855), QUIC sniffer
zero-filled tails (XTLS#6882), XDNS resolver deadlock (XTLS#7089), gRPC redial
context (XTLS#6877), scenario test process leaks (XTLS#6863).

Conflict in proxy/wireguard/tun_linux.go: took upstream's loop guard
while keeping the local errors.New lint fix.
TaiLerV pushed a commit to TaiLerV/Xray-core-up that referenced this pull request Oct 7, 2026
The dispatcher caches the datagrams of a UDP flow without their
boundaries. SniffQUIC derived keys from the Destination Connection ID of
every Initial packet it met and merged their CRYPTO frames into one
stream, so Initial packets of another connection in the same flow
corrupted the ClientHello. Bytes after the last packet of a datagram,
which receivers ignore, ended sniffing unless they were zeros.

Sniff the connection of the first Initial packet that decrypts and skip
Initial packets of other connections, as Hysteria 2.13.0 does. When the
bytes after a packet do not parse, resume at the next Initial packet of
that connection, found by its version and Destination Connection ID; this
covers Firefox's zero padding, which the zero skipping from XTLS#6882 handled,
and any other tail.

Tests interleave datagrams of three captured connections and append a
non-zero tail; both failed before this change. FuzzSniffQUIC checks that
no input panics the sniffer or is written to; 90s and 60s local runs
found nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fanymagnet pushed a commit to fanymagnet/Xray-core that referenced this pull request Oct 8, 2026
@hagz0r

hagz0r commented Oct 9, 2026

Copy link
Copy Markdown

thanks a lot, saved our prod, waiting for this PR to be in next release

@hagz0r

hagz0r commented Oct 9, 2026

Copy link
Copy Markdown

无论真实存在与否 这的确是符合RFC的报文

This specific edge case appearing in Gemini in Firefox

BobJustFry added a commit to BobJustFry/xray-core that referenced this pull request Oct 18, 2026
- quic sniff: zero-padded datagram tails skipped (upstream XTLS#6882); a complete CRYPTO ClientHello without SNI returns ErrQUICNoSNI and a flow that does not start with an Initial returns ErrQUICNotFirstInitial at once, so the dispatcher stops waiting (no-SNI decision 1 ms instead of the 200 ms budget). QUIC wait budget unchanged.
- dispatcher: per-flow QUIC outcome counters in VupenSniffStats (quic[ok nosni notfirst notquic more other]); arrival gaps (dt=...) in the sniff timeout line; direct-miss banner only when the hinted domain would route to a direct outbound, otherwise an Info no-domain line; route memory for repeated UDP flows (src -> IP dst, 60 s from last use, LRU 512) reuses the outbound without sniffing, invalidated by a route generation bumped on network epoch, AUTO node change, spill/unspill and Apple setting change; empty-TCP extra wait off (VupenSniffEmptyTCPWait = 0).
- tun: gVisor connection-refused handshakes counted (hsRefused=) and logged at Debug; websocket: dial errors within 15 s of a network change logged with a [netchange] hint.
- router: VupenSetAppleViaVpnMode(mode): 0 off, 1 skip the vupen-apple-direct rule while AUTO is on the LTE tier, 2 always skip it (whitelist node picked manually); VupenSetAppleViaVpnOnLte(bool) kept as alias 1/0; invalid mode ignored with a warning; atomic, no restart, log line on change, per-router decision log (CR-103) kept. VupenAutoState: appleViaVpnMode, appleViaVpnOnLte (mode != 0), appleViaVpnActive (mode 2, or mode 1 and on LTE).
- tests: encrypted QUIC v1 fixtures (SNI, no SNI incl. halves/gaps/out of order, 0-RTT first, zero tails), route memory recall/generation/TTL/cap/concurrency, QUIC counters, timing, Apple matrix mode x tier x network x marker, mode API, manual node in mode 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

4 participants