Inside the Message Parser: Pointers, Counts and 16-Bit Traps

Site Admin · 3 Dec 2026 · Core Internet Infrastructure

A DNS message is a 12-byte header, four counted sections, backward compression pointers and 16-bit lengths. The negative cache builds records in a 64 KiB buffer and stores their length in 16 bits. That is where both bugs live.

Every DNS feature ends in the same code: a 12-byte header, four counted
sections, names that can point backward at earlier names, and lengths stored in
16 bits. Both 2026 bugs are properties of that design.

The wire format

A DNS message begins with a fixed 12-byte header:

Then come the sections, in order: question, answer, authority, additional. Each
record has a name, a type (16 bits), a class (16 bits), a TTL (32 bits), and an
RDATA length (16 bits) followed by that many bytes of RDATA.

Nothing in that layout is self-describing beyond the counts: the parser must
trust them enough to iterate and distrust them enough not to run off the end of
the buffer.

Names and compression

A DNS name is a sequence of labels. Each label starts with a length byte (six
bits of length, two bits of flags), followed by that many bytes. A name ends
with a zero-length label. Labels are capped at 63 bytes and a name at 255 bytes
on the wire.

Compression is the clever part. If a name (or a suffix of a name) has already
appeared earlier in the message, the encoder can replace it with a pointer:
two bytes whose top two bits are 11, leaving 14 bits of offset from the start
of the message. The decoder follows the pointer, copies the name it finds there,
and continues.

Pointers must point strictly backward. That rule prevents infinite loops — a
pointer can never point at itself or forward into data not yet parsed — but it
does not bound the work. A pointer that points at another pointer adds no
bytes to the name. A chain of pointers can be walked over and over, and
thousands of names can each point into the same long chain. That is the shape
of CVE-2026-19630: not a loop, but an amplifier.

The parse path

In BIND 9 the path runs roughly:

dns_message_parse()
  early_sanity_check()
  getquestions()        -> dns_name_fromwire()
  getsection()          -> dns_name_fromwire()
                           getrdata()
                             dns_rdata_fromwire()

dns_name_fromwire() is the decompressor. It tracks a marker to enforce
backward-only pointers, copies labels into a target buffer, and follows pointer
chains. getrdata() parses the record body; if the scratch buffer is too small
it doubles the buffer and retries. dns_rdata_fromwire() dispatches to a
per-type parser, of which BIND has dozens.

The parser is called for every message — queries, responses, updates,
transfers, NOTIFY, TSIG traffic, DNSSEC proofs. No unauthenticated path skips
it.

The 16-bit ceiling

DNS was designed in 1983, when 16 bits looked generous. The protocol is full of
16-bit lengths:

The edge appears at 65,536 — one more than
a 16-bit field can hold. Assign 65,536 to a 16-bit field and it becomes zero. That is not a rounding error; it is a silent
category change from "a full record" to "no record at all".

The negative cache path

Negative caching (RFC 2308) is how a resolver remembers that a name does not
exist. When an authoritative server returns NXDOMAIN or NODATA, it includes the
zone's SOA record in the authority section so the resolver knows how long to
cache the negative answer.

dns_ncache_add() takes that authority section and assembles a compact cache
record. It uses a stack buffer:

unsigned char data[65536];

and writes each record's length with isc_buffer_putuint16(). A record that
fills the buffer exactly is 65,536 bytes long. The length field holds zero. The
zero-length record then passes the size checks in
dns_rdataslab_fromrdataset() — because zero is small — and is committed to the
cache. When a later query reads it, the reader trusts the length, walks a
zero-byte buffer, and hits an assertion.

That is CVE-2026-19667. The next part looks at the smaller failures around it
before taking both bugs apart in detail.

Next: Part 6 — the smaller failures: a 2026 CVE batch that all lives in the
same message path, and why "only a DoS" is not a small claim.