From 5ef5406a0c622f419b700c06b179b7be0a6c9925 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Mon, 30 Nov 2026 20:44:13 +0000 Subject: [PATCH] Fix possible DNSSEC bypass in prove_non_existence_nsec() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to 전승훈 for finding this bug, it's a repeat of the problems seen in CVE-2026-4891. Their explanation: In prove_non_existence_nsec() around line 1296 of dnssec.c, the second extract_name() call uses plen as its bound instead of psave+rdlen. So if a crafted NSEC record has a Next Domain Name that's longer than rdlen declares, extract_name() happily reads past the rdata boundary (still within the packet, so no crash), and then rdlen -= (p - psave) goes negative. The while (rdlen > 0) bitmap loop never runs, and the function returns 0 as if non-existence was proven, without ever checking the type bitmap. --- CHANGELOG | 5 +++++ src/dnssec.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b34d4ea..fe34575 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,11 @@ version 2.94 which arrises from the same mistake, Credit to Georgi Steffenhagen (ServerTec IT Engineering) for this one. + Fix possible DNSSEC bypass in prove_non_existence_nsec() + Thanks to 전승훈 for finding this bug, it's + a repeat of the problems seen in CVE-2026-4891. + + version 2.93 Fix a corner-case in DNSSEC validation with wildcards. If we have a wildcard record *.example.com and receive a query for diff --git a/src/dnssec.c b/src/dnssec.c index 8b70aa4..29300f9 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -1292,7 +1292,9 @@ static int prove_non_existence_nsec(struct dns_header *header, size_t plen, unsi GETSHORT(rdlen, p); psave = p; - if (!extract_name(header, plen, &p, workspace2, EXTR_NAME_EXTRACT, 0)) + /* If the name is longer that rdlen, then our bitmap code gets + very confused. Doing that deliberately can bypass type bitmap checks. */ + if (!extract_name(header, plen, &p, workspace2, EXTR_NAME_EXTRACT, 0) || (p - psave > rdlen)) return DNSSEC_FAIL_BADPACKET; /* If NSEC comes from wildcard expansion, use original wildcard