LXR / security researcher
RSS Contact
NOTEBOOK / RESEARCH / 0x02

CVE-2026-101339: the HIP record that walks off the end of the buffer

2026-10-1410 MIN READDISCLOSED CVE
NSDSIMDZONESTACK OVERFLOW

What this is about

An authoritative DNS server is the machine that holds the real answers for a domain. It loads those answers from a zone file, a plain text file in a format that has been around since the 1980s. NSD, from NLnet Labs, is one of the more widely deployed ones, running on three root servers and at a number of top-level domain registries by the vendor's own account. Since 4.10.0 it parses those files with simdzone, a SIMD-accelerated library it vendors as a submodule.

This is the second of two bugs I found in that parser. The first one was in TXT-style strings. This one is in a record type most people have never had to think about.

How I got here

This started in bug bounty recon. I was mapping the infrastructure behind a few programs, saw that the authoritative nameservers for one of them ran NSD, and got curious about software I had not looked at before.

A zone file is untrusted text that a DNS server turns into memory at startup, so the parser reading it is worth more attention than it usually gets. And since 4.10.0 NSD does not do that parsing itself: it hands the job to simdzone, a library rebuilt around wide SIMD stores, which is exactly where per-byte bounds checks tend to get traded away.

I wrote two libFuzzer harnesses against it, one for the string API and one for the file API, and ran them under ASan.

Then I spent a while fighting my own results. The fuzzer found five bugs quickly, and three of them were shallow enough that it kept rediscovering them. Every campaign filled with the same $INCLUDE and comment-escape crashes and never reached anything deeper.

So I patched those five in the local tree and ran it again. Two findings surfaced underneath, both through the file API, both on 14 September. One was the string bug in the other post. The other was a record type I had never had reason to think about.

HIP, and the loop that forgot

HIP is the Host Identity Protocol record. Its RDATA holds a host identity tag, a public key, and then a list of rendezvous server names, which is a variable-length list of DNS names appended one after another.

C
/* src/generic/types.h, parse_hip_rdata() */
take(parser, token);
while (is_contiguous(token)) {
if ((code = parse_name(parser, type, &fields[5], rdata, token)) < 0)
return code;
take(parser, token);
}
...
return accept_rr(parser, type, rdata);

Neither the loop nor parse_name() checks rdata->limit. What makes this stand out rather than look like an oversight in sloppy code is that the same function bounds everything else. The HIT length is range-checked against 255 + 4. The rendezvous list is the one thing that is not.

Once I had root-caused the crash I wanted to know whether this was one omission or a habit, so I swept all 59 parse_*_rdata functions in types.h and all 15 in svcb.h for the same shape: a loop writing into rdata->octets without consulting rdata->limit. Most were fine, and fine in instructive ways. parse_apl_rdata derives the remaining space from rdata->limit and passes it down. parse_generic_rdata tests it directly before each write. The codebase has a house style for this, and parse_hip_rdata is the one place that departs from it.

The buffer being overrun is zone_rdata_buffer_t, which is ZONE_RDATA_SIZE (65535) plus ZONE_BLOCK_SIZE (64), so 65,599 bytes, and it is supplied by whoever calls the library. I bisected the threshold in a release build with no sanitizer, varying only the number of rendezvous names:

cumulative RDATA
result
65,535
clean
65,597
clean
65,598
first out-of-bounds write

The write is contiguous from the first byte past the buffer, and it grows with the number of names at roughly 74 octets each. That linearity is the part that matters, because it means the attacker picks the distance.

What sits past the end

Two assertions in accept_rr() state the invariant that was violated:

C
assert(rdata->octets <= rdata->limit);
...
assert(length <= UINT16_MAX);
int32_t code = parser->options.accept.callback(parser, ..., parser->user_data);

Both are assert(). Both are gone from every release build, because release builds define NDEBUG. So the one place in the library where every rdata parser passes through, and where the invariant is actually written down, enforces nothing in the code anybody ships.

The third line is the interesting one. zone_parser_t embeds zone_options_t options at offset 0, which puts options.accept.callback inside the region the overflow walks through, and accept_rr() calls it immediately, on the same record.

Mapping the ground past the buffer, in a build matching NSD's own declaration order:

OUTPUT
+0 .. +327 zone_name_buffer_t owner (328 bytes)
+328 zone_parser_t parser begins
+368 options.log.callback
+384 .. +391 options.accept.callback <- target
+448 / +456 / +464 parser->owner / ->rdata / ->file <- accept_rr dereferences these

So there is a 56-byte landing window at [392, 448). Land inside it and you have replaced the callback while leaving intact the pointers accept_rr needs on its way to calling it. Overshoot and you clobber parser->file, and the process faults earlier in parse_name, which is why casual testing of this bug shows nothing but a segfault. 890 rendezvous names puts the write 436 bytes past the end, inside the window.

The call target is fully chosen, not merely corrupted. simdzone accepts \DDD decimal escapes in labels, so any byte can be placed at any offset, including NUL. Forging 0xdeadbeefcafebabe, 0x0000555555554321 and 0x0011223344556677 each produced exactly that value in r11 at call *%r11. And the callback's first argument is parser, which also lies inside the overflow, so a NUL-terminated string written at parser + 0 together with &system in the callback slot gives system("whatever you wrote").

SHELL
$ zone-bench parse example.com. zb_pwn.zone
Selected target haswell
Parsed 0 records
$ cat /tmp/sz006_zb
uid=1000(lxr) gid=1000(lxr) groups=1000(lxr),...

Exit code 0, in a -O2 -DNDEBUG build with no sanitizer. The parser reports success.

I checked whether this was specific to NSD's code, and it is not. The exploitable layout is the one the public API produces. Four independent callers put the target pointer at the identical +384 offset at -O0, -O1 and -O2: simdzone's own bench.c, NSD's zonec.c and ixfr.c, and a third-party tool, schlarpc/zone2jsonl, which integrates simdzone exactly as the project documents it. I reproduced code execution against zone2jsonl too. Anyone following the documented integration pattern lands on the same layout.

Containment depends on who is parsing. In the NSD daemon the zone load happens after chroot() and setresuid(), so code runs as the unprivileged nsd user inside the chroot, which is still enough to forge answers for every zone that instance serves. nsd-checkzone has no containment at all. It is 193 lines with no setuid, no setgid, no chroot, no sandbox, and it is commonly run as root on a file an operator was handed.

The fix, and a sweep that nearly lied to me

Instead of the narrow HIP patch he had sent first, Willem went generic: add a limit parameter to scan_name() in both the SIMD and the fallback implementations, and bound-check both of parse_name()'s exits. That closes the whole class rather than the one caller, which matters because his stated aim is adding more record types later.

Verifying it:

0x1All five HIP reproducers are rejected with "Invalid Rendezvous Servers in HIP". The guard region goes from 66 and 108 octets past the object down to 0.
0x2It holds across all three kernels, including the scalar fallback. Pristine fallback had accepted these too, so this was never a SIMD-only defect, unlike the string bug in the other post.
0x3The boundary is exact on both the absolute and the relative: branch, driven by measured rdlength: 65528 through 65535 accepted, 65536 through 65543 rejected. Pristine accepted those, with the rdlength wrapping around to 0 through 7.
0x4213 real NSD zone files, zero behavioural differences.

The first pass of that sweep told me the patch was broken. It appeared to show records 1 to 3 octets over the limit still being accepted, which would have meant the fix did not hold at the boundary. I had anchored the sweep on a filename, wire_max_65535.zone, and assumed the name described the contents. Measuring the actual rdlength showed that file carries 65,512 octets, so those cases were legal and the patch was right. I caught it before it reached him, but only because I measured instead of trusting the label on the tin. If I had sent it, I would have spent his time arguing the patch was wrong.

How NLnet Labs describes it

From nlnetlabs.nl/downloads/nsd/CVE-2026-101339.txt:

When reading zone files, a specially crafted and formatted HIP resource record can cause an out of bounds stack overwrite which can be exploited for execution of arbitrary commands.

and:

A HIP resource record that fills the RDATA near or at is limit, and has another dname RDATA field (a HIP Rendezvous server) can overwrite the stack with up to 191 bytes of attacker controlled data.

They also state the precondition, in the same words used for the other three advisories in this release: zone files NSD writes out itself, such as those for zones where it is secondary, are not formatted this way. The file has to be fed to NSD directly, which as they note can still happen through an operator-controlled provisioning system.

Affected versions are NSD from 4.10.0 up to and including 4.15.2. The fix is in NSD 4.15.3, with a standalone patch against 4.15.2 at patch_CVE-2026-101339.diff.

Timeline

Date
Event
2026-09-15
Reported to NLnet Labs, PGP encrypted
2026-09-22
Patch received, CVE confirmed as forthcoming
2026-09-30
Generic scan_name patch received, verified the same day
2026-10-14
simdzone 0.2.7 and NSD 4.15.3 released

Thanks

Thanks to Willem Toorop at NLnet Labs. First reply within days, a patch that closed the whole class rather than the one caller, and a release shipped about four weeks after the report. He engaged with the technical detail himself instead of routing it to a form.

← PREVIOUSFollowing a MAVLink command from ground station to autopilotNEXT →CVE-2026-101341: a TXT record that runs commands on your DNS server