You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
write_name compression can point to the wrong name when a label contains a dot #541
DnsOutPacket::write_name records each name suffix it has written so later names can compress against it. The key for that map is built by joining the unescaped labels with .:
let remaining:String = labels[i..].join(".");
A dot inside a label (RFC 6763 section 4.3) looks the same in that key as a dot between labels. So two different names can share a key, and the second one is written as a pointer to the first, which turns it into a different name on the wire.
Both names get the key L.A.B.local. The packet after the header is:
03 "L.A" 01 "B" 05 "local" 00 00 0c 00 01 first question, written in full
c0 0c 00 0c 00 01 second question, pointer to offset 12
The second question should start with 01 "L" 01 "A" 01 "B" 05 "local" 00. A receiver decodes it as the first name instead.
The same applies to a suffix: x.L.A.B.local. written after the first name also compresses against it at L.A.B.local.
Impact: it needs two names in one packet that differ only in where a label boundary falls, so it should be rare. Names learned from the network are re-emitted (for example as known answers), so a peer can cause it. The result is a wrong name in the packet, not a crash.
Possible fix: build the key so that label boundaries stay distinct, for example by escaping . and \ in each label before joining, or by keying on the labels themselves.
Noticed while reviewing #540. This is separate from that PR and from #536: the key is built only on the write path.
Activity
fix: preserve label boundaries in DNS name compression
fix: preserve label boundaries in DNS name compression (keepsimple1#542)