TLS sniffer does not read SNI from a ClientHello split across TLS records (and large post-quantum ClientHellos make #7286's case more common)
I maintainer di solito rispondono entro 1 giorno
@Fangliding ci sta già lavorando.
Dal 1/12/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- networking
Direzione di ricerca
Read common/protocol/tls/sniff.go around SniffTLS and ReadClientHello, then inspect app/dispatcher/default.go:417-427 to understand how incomplete data is handled. Reproduce with ClientHellos split across TLS records and with a valid record arriving in several reads. Done when both shapes preserve SNI for domain routing and the accumulated handshake stays within the existing 8 KiB payload buffer.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Follow-up to #7286. I understand from that discussion that the sniffer is best-effort and is not meant to be a firewall, and I'm not asking for it to block anything. This issue is about valid ClientHellos produced by normal clients, which the sniffer currently can't read, so domain routing rules don't apply to them.
Version: v26.11.9 (676eaf66f8f0), official Linux x86-64 release. Line numbers below are from that tag. On main (919d0ae8eb54, 2026-11-30) sniff.go is unchanged; the dispatcher loop is the same logic, now at app/dispatcher/default.go:417-427.
1. ClientHello split across TLS records (not covered by #7286)
RFC 8446 §5.1 allows a handshake message to be split across several TLS records. SniffTLS parses only the first record (common/protocol/tls/sniff.go:146-152, ReadClientHello(b[5:5+headerLen], h)). If the SNI is in a later record, or the first record holds only part of the ClientHello, sniffing fails even when all the bytes arrived in a single read.
In our tests (dokodemo-door with sniffing.destOverride: ["tls"], routeOnly: true and a domain: ["full:a.test"] rule), all 167 of 167 multi-record ClientHellos were routed by IP instead of by domain. The single-record versions of the same ClientHellos were routed correctly.
2. Single record arriving in 3+ reads (same root cause as #7286)
SniffTLS returns common.ErrNoClue when a record header is present but the record is incomplete (sniff.go:147). The dispatcher stops after two ErrNoClue results (app/dispatcher/default.go:409-419).
#7286 used 100-byte chunks to show this. The relevant real-world case is post-quantum key exchange. ML-KEM-1024 shares, several hybrid key shares, or ML-KEM-768 plus a session ticket push a normal single-record ClientHello past ~2,896 bytes, which is 3+ TCP segments at a 1,448-byte MSS.
Over a 1,500-byte MTU veth link (offloads off), these were our results:
-
Segments 10–30 ms apart: every ClientHello delivered in 3–4 segments lost domain routing (58 of 58). None of the 142 delivered in 1–2 segments did.
-
Segments sent back to back: single-record ClientHellos of 4.2–5.3 KB were sniffed correctly (52 of 52), because they coalesced into fewer reads.
-
Unmodified OpenSSL 3.5.9 client (one write): 2,977 B and 4,648 B ClientHellos were sniffed correctly in 18 of 18 attempts each, even with
netem delay 5ms 2msornetem rate 10mbiton the client's uplink.
So mild jitter and a 10 Mbit/s uplink weren't enough to trigger this. It needs larger gaps between segments, for example from loss and retransmission or sender pacing. I haven't measured real links. Default OpenSSL 3.5 ClientHellos (X25519MLKEM768, ~1.3–1.7 KB) were not affected.
Suggested change (small, keeps the best-effort design)
- In
SniffTLS, returnprotocol.ErrProtoNeedMoreDatainstead ofcommon.ErrNoCluewhen the record header is valid (type 0x16, version 0x03xx, length ≤ 2^14) and the record is just incomplete. The dispatcher's existing 200 ms deadline still bounds the wait. This is the fix proposed in #7286. - Concatenate consecutive handshake records until the ClientHello's 4-byte handshake length is satisfied, bounded by the existing payload buffer (
buf.Size, 8 KiB), before callingReadClientHello.
I'm happy to send a PR with tests for both if that would be welcome.
Reproduction
Two local TLS 1.3 servers: :8500 with only TLS_CHACHA20_POLY1305_SHA256, and :8509 with only TLS_AES_256_GCM_SHA384. The negotiated cipher shows which route was taken.
{
"inbounds": [{"listen": "127.0.0.1", "port": 7023, "protocol": "dokodemo-door",
"settings": {"address": "127.0.0.1", "port": 8509, "network": "tcp"},
"sniffing": {"enabled": true, "destOverride": ["tls"], "routeOnly": true}}],
"outbounds": [{"tag": "ip-default", "protocol": "freedom"},
{"tag": "a-test", "protocol": "freedom", "settings": {"redirect": "127.0.0.1:8500"}}],
"routing": {"rules": [{"type": "field", "domain": ["full:a.test"], "outboundTag": "a-test"}]}
}
python3 split_hello.py 127.0.0.1 7023 a.test # domain route (0x1303)
python3 split_hello.py 127.0.0.1 7023 a.test --records 2 # IP route (0x1302)
python3 split_hello.py 127.0.0.1 7023 a.test --segments 3 --delay 0.02 # IP route (0x1302)
split_hello.py is a small standard-library script that sends one real OpenSSL-generated ClientHello re-framed as requested; I can share it with the maintainers on request. These expected outputs come from our fuzzer runs with the same shapes.
Tested only on our own machines. No third-party servers were involved.
Sathish Kumar P A
- Lingua principale
- Go
- Stelle
- 43.3k
- Fork
- 6.2k
- Merge medio
- 2g 11h
- PR unite (30g)
- 55
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di XTLS/Xray-core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di XTLS/Xray-core
Issue simili
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openclaw/crabbox#3249 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
ec2-subnet, security-group and internet-gateway skip all resources when one is deleted during the scanForse già presa @toabctl l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
gruntwork-io/cloud-nuke#1208 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
snowflakedb/gosnowflake#1872 ·
-
MCP `shadow` says `out` is a folder, but for TS, Python, C, Go and Ruby it is the module's fileApertagood first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
erkamyaman/rust-anything#1328 ·
I maintainer di solito rispondono entro 1 giorno