TLS sniffer does not read SNI from a ClientHello split across TLS records (and large post-quantum ClientHellos make #7286's case more common)
Los mantenedores suelen responder en 1 día
@Fangliding ya está trabajando en esto.
Desde el 1/12/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 57/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- networking
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Go
- Estrellas
- 43.3k
- Forks
- 6.2k
- Merge medio
- 2 d 11 h
- PR fusionados (30 d)
- 55
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de XTLS/Xray-core
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de XTLS/Xray-core
Issues similares
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openclaw/crabbox#3249 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
ec2-subnet, security-group and internet-gateway skip all resources when one is deleted during the scanPosiblemente ocupada @toabctl la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
gruntwork-io/cloud-nuke#1208 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 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 fileAbiertogood first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
erkamyaman/rust-anything#1328 ·
Los mantenedores suelen responder en 1 día