DanielLavrushin 报告 b4 在 DNS 提示后处理分段 ClientHello 的两处缺口
DanielLavrushin 报告,b4 使用 DNS 主机提示处理分段 ClientHello 时仍有两处缺口:首段解析出的域名不匹配提示 set 后,提示只在当前包被丢弃,后续无域名分段仍可能使用它,注入来自不匹配 set 的伪造包;在暂存首段、ClientHello 分为三段或更多的情况下,中间段可能提前释放首段,最终解析出域名时无法再回退到已学习地址的 set。他称 main 与 #742 分支均有这些行为,并非 #742 引入的回归;已合并的 #742 明确将它们留给 #748 处理。他提出按连接停止应用失配提示、保留暂存状态等方向,尚不是已实现或发布的修复。
作者原文@DanielLavrushinFound in review of #742 (the fix for #658). Both behave the same on main and on the PR branch, so they are not regressions of that PR, but they are the same family: a split ClientHello after a DNS host hint gets fakes that do not match what the same hello gets in one segment.
1. A hint dropped by the name in segment 1 still fakes segment 2
When the name sits in segment 1 and matches no set, the hint is dropped for that packet only (handler.go#L952-L956): the drop clears local variables and the hint stays stored. Segment 2 carries no name, so
isClientHellois false,lookupHostHint(handler.go#L566) matches it again and the hinted set fakes it.Probe: a fake-only set (
newFakingSet(false)), a hint 10.0.0.1 -> 1.2.3.4 for that set,helloWithEarlySNI("other.example.com")cut at 600, either first byte of segment 2:| learned address | segment 1 | segment 2 |
| --- | --- | --- |
| yes | fake at 1000 | fake at 1600 |
| no | none | fake at 1600 |Without a learned address the only fake is a fake ClientHello in the middle of the record, from a set the name does not match. With one, every such hello gets two fakes, the #658 symptom without the 1 in 256.
Direction: once the connection's hello has named a host that does not match the hint's set (
tlsCache.Lookup(connKey)), stop applying the hint to that connection's later packets. Keep the "a DNS host hint" row ofTestEveryPathSendsASplitClientHelloInSequenceOrder, where the name matches the hinted set and both segments get a fake by design.2. A held hello in three or more segments loses the learned set after a dropped hint
#742 lets a held segment 1 count as the record start, so a hello split in two takes the learned set after a dropped hint (fakes at 1000 and 1600, like the other held paths). With three or more segments, the nameless middle segment claims segment 1's hold in
feedLocked(clienthello.go#L187), finds no name, and segment 1 is released with an accept under the passive hint set. The joined entry is stored again without the hold (clienthello.go#L195). The segment that completes the name has no hold and is a continuation, so the fallback refuses a set that neither fragments nor desyncs.Probe: a passive set behind a hint for
hinted.example, a fake-only set that learned 1.2.3.4,helloWithLateSNI("other.example.com")queued as 0-300, 300-600 and 600-end:| shape | fakes | verdicts |
| --- | --- | --- |
| three segments | none | accept 1, accept 2, accept 3 |
| two segments (#742) | 1000, 1600 | drop 2, drop 1 |
| one segment | 1000 | drop 1 |Direction: keep the hold attached to the joined entry until the name is known, or record on the connection that segment 1 was held and released, and add a three-segment held row to the hint-drop tests. This changes the hello hold, so it needs its own review of the hold timeout and the release paths.