A minute on DNS
Every time you open a website your machine asks a question: what address belongs to this name? Somewhere at the end of that chain sits an authoritative nameserver, the machine that holds the real answer for a domain. It reads its answers from a zone file, a plain text file listing names and what they point to.
NSD is one of those nameservers. NLnet Labs writes it, and by their own account three DNS root servers and many top-level domain registries run it as part of their setup. When NSD starts up, or when an operator runs nsd-checkzone to validate a file before serving it, the zone file gets parsed.
So the attack surface is this: a text file, parsed by a fast C parser, at startup, usually as root when run through the checking tool.
Why I looked here
This started in bug bounty recon. I was mapping out the infrastructure behind a few programs, and the authoritative nameservers for one of them were running NSD. I had not looked at NSD before, so I went to read about it, found the deployment picture above, and got curious enough to go and see what the code actually does with input.
What it does with input is read zone files. A zone file is where untrusted text becomes memory inside a DNS server. An operator is handed a file, or a provisioning system emits one, and the nameserver reads it at startup. Whatever the parser gets wrong there, it gets wrong on attacker-shaped input, early, and usually at the highest privilege the process will ever hold.
Since version 4.10.0, NSD does not do that parsing itself. It vendors simdzone as a submodule, a separate library built around SIMD instructions so it can read very large zones fast. A parser rewritten for speed is worth reading carefully, because per-byte bounds checks are the first thing traded away for a wider store. Checking every byte is the thing you are trying to stop doing.
I wrote two libFuzzer harnesses, one driving the string API (zone_parse_string) and one driving the file API (zone_parse), and ran them under ASan.
Then I spent a while fighting my own results. The fuzzer found bugs fast, five of them, and three were shallow enough that it kept rediscovering them. Every campaign filled up with the same $INCLUDE and comment-escape crashes and never got past them. A fuzzer that keeps handing you the bug you already know about has stopped looking anywhere new.
So I patched those five in the local tree and ran the campaign again. Two findings came up underneath, both through the file API, both on 14 September. One was the HIP record. The other is this one.
The part where I nearly threw it away
My first audit wrote this one off. The note read "canary intact, write confirmed under ASan only", which in practice means not worth a report.
That verdict was wrong, and it was wrong because of my harness rather than because of the bug. The audit script drove zone_parse_string(). This defect is only reachable through zone_parse(), the file API. Same binary, same zone, same release build:
A sanitizer-only curiosity became a 1,171-byte out-of-bounds write with a success return code, purely by calling the right entry point. The bug had not changed. The instrument had.
Reading the parser
simdzone handles character-strings in src/generic/text.h, in a function called scan_string(). Its job is to copy one string out of the zone text into the wire-format buffer, and to refuse to write past the end of that buffer. The caller hands it a limit pointer for exactly that purpose.
The function starts by copying a fixed 32 octets, unconditionally, using a single SIMD store. That is the trick that makes it fast: it does not check the length first, it copies a whole register's worth and sorts out the details afterwards. Then it works out how many of those octets were real.
Here is the part that caught my eye:
That return is the bug. It is taken for any string shorter than 32 octets, which is most strings in most real zone files. It happens after the 32-octet store has already landed, and before the function reaches either of the two places where it consults limit.
The function does bound itself correctly. Further down there is a loop that runs while (length && wire < limit), and an exit check if (length || (wire > limit)) return -1. Both are right. The early return reaches neither of them. limit is a parameter that this code path never reads.
I spent a while convinced I had misread it, because the two correct checks are sitting a few lines below and it looked too plain. The thing that settled it was reading the caller.
Why nothing downstream catches it
In src/generic/format.h, parse_string() trusts the returned length:
The guard tests equality. Not greater-than-or-equal, equality. So it fires on the exact moment the cursor lands on the limit, and it is blind to a cursor that has stepped over it. The assertion underneath would have caught the overshoot, and it is removed from every release build by -DNDEBUG.
That gives the defect its character. One short string pushes rdata->octets past rdata->limit, and from then on nothing brings it back. Every further short string in the same record writes its length byte and its content at a growing offset past the end of the caller's buffer. The attacker chooses how far by choosing how many strings to write.
Only the SIMD kernels are affected. src/fallback/text.h is a separate implementation that bounds correctly. Forcing the kernel with ZONE_KERNEL, haswell and westmere both run the payload and fallback rejects it. A build whose CFLAGS carry an explicit baseline -march compiles neither SIMD kernel and is not affected at all, which is why some distribution packages escaped.
From overflow to command execution
A contiguous overflow of attacker-chosen length is bad, but I wanted to know what was actually sitting past the end of that buffer. In simdzone's own zone-bench, in NSD's zonec.c, and in third-party consumers, the buffers are declared as locals in the calling function, so the answer is: the caller's own stack frame, including the parser struct.
zone_parser_t embeds zone_options_t options at offset 0. And accept_rr(), which runs immediately after a record is parsed, does this:
A function pointer, inside a struct, in the region the overflow walks through, called on the same record that caused the overflow. Write &system into that slot, place a NUL-terminated command string at parser + 0 where the callback's first argument points, and the parser calls system("your command") on its own.
Sweeping all 256 byte values through the overflowing strings, 254 reach memory verbatim, including NUL. Only " and \ are excluded, since those are the quoting characters in zone syntax.
The reproducer is a plain zone file with one TXT record. First 255 strings of 255 octets each, to march the cursor up to the limit. Then short strings under 32 octets, each one taking the unchecked early return. No fuzzer blob and no escape sequences, because \DDD escapes take the loop path, and the loop path checks the bound.
On a pristine git archive v0.2.6 export, built -O2 -g -DNDEBUG with no sanitizer and with -fstack-protector-strong, gcc 16.2.1 on Arch x86_64:
Exit code 0. Three runs out of three. The same payload against nsd-checkzone:
Also exit 0, also 3/3. The tool whose entire purpose is to tell an operator whether a zone file is safe to serve declares the file valid while the file executes a command.
The stack canary does not help. zone-bench is built with -fstack-protector-strong and still dies at call *%r11 with SIGSEGV rather than SIGABRT, because the hijack goes through a function pointer in a struct, inside a function that never gets to return, so the canary is never checked.
Two conditions gate the result. ASLR has to be off for the final step, so the PoC runs under setarch -R. Control of the call target and of the first argument is byte exact either way, but the address you write has to be correct, and with ASLR on the process takes SIGSEGV at exactly that address instead of executing. And a SIMD kernel has to be compiled in. Where the first condition does not hold, the outcome is a crash of whatever process was loading the zone.
How NLnet Labs describes it
Their advisory is at nlnetlabs.nl/downloads/nsd/CVE-2026-101341.txt, and their summary is tighter than mine:
When reading zone files, a specially crafted and formatted resource record containing a series of strings (TXT, NINFO, SPF, AVC, RESINFO and WALLET) can cause an out of bounds stack overwrite which can be exploited for execution of arbitrary commands.
And their description:
Tokens of text in RDATA (of for example TXT records) under 32 bytes are not checked to stay within the space reserved for the RDATA allowing for arbitrary sized out of bound stack writes, including an overwrite of a callback function pointer which is called directly after parse.
Two things in there are worth noting. The record types are wider than just TXT, because NINFO, SPF, AVC, RESINFO and WALLET all take the same series-of-strings parse path. And they state the operational precondition plainly: zone files NSD writes itself, such as those for zones where it is secondary, are not formatted this way. The file has to be fed to NSD directly, though as they point out, that can come from an operator-controlled provisioning system.
Affected versions are NSD from 4.10.0 up to and including 4.15.2.
The fix
One line, in src/generic/text.h:
The early return now consults the limit it was always being handed.
I checked it before confirming. Both exploit zones are rejected with "Invalid TXT in text" and exit 1, while the control zone still parses. A boundary battery of 7 zones across 3 kernels, 21 runs, produced zero mismatches, and made both SIMD kernels agree with the fallback implementation as an oracle, including that an exact 65535-octet fit stays valid and one octet more is refused. Then 213 real NSD zone files, with zero behavioural differences against pristine.
One detail from that check is worth passing on to anyone fixing a bug of this shape. There is an obvious smaller fix available: change the caller's == in format.h:116 to <= and let the equality guard catch overshoots too. That passes the vendor's new regression test. It does not close the bug. A zone that fills to limit - 1 and then writes a final 31-octet string is still accepted, with an rdlength of 30 reported for 65,566 octets of actual rdata. Only the guard inside scan_string rejects it. A test that a wrong fix passes is a necessary gate, not a sufficient one.
Timeline
If you run NSD, the fixed release is NSD 4.15.3. There is also a standalone patch against 4.15.2 at patch_CVE-2026-101341.diff.
Thanks
Thanks to Willem Toorop at NLnet Labs. First response in days, patches that worked, and a release that shipped a little over three weeks after the report. He engaged with the technical detail rather than routing it to a form, and the whole exchange stayed PGP end to end. That is a lower bar than it should be and plenty of vendors do not clear it.