From 035eaa22adff7ba28d2f2cbaf946eb86f2e5f880 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Mon, 30 Nov 2026 21:17:40 +0000 Subject: [PATCH] Fix OOB read in find SOA - attacker-controlled minTTL 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: find_soa() reads two DNS names from an SOA record's RDATA using extract_name() — the MNAME and RNAME fields. Both calls pass qlen (the whole-packet bound) rather than a bound derived from the current record's rdlen. If either name contains a compression pointer or is long enough, p can be advanced beyond the actual end of the SOA RDATA. The subsequent length check CHECK_LEN(header, p, qlen, 20) succeeds whenever the advanced pointer still happens to fall within the overall packet, even if it is now past the RDATA boundary. The code then executes: GETLONG(minttl, p); /* reads 4 bytes from the wrong location */ *ttlp = minttl; The result is that *ttlp is set to 4 bytes read from an arbitrary location inside the packet rather than the SOA's actual minimum TTL field. A crafted upstream reply with a DNS-compressed MNAME or RNAME in the SOA RDATA can therefore cause dnsmasq to cache any attacker-chosen TTL for negative responses. Impact An attacker who controls or can spoof an upstream DNS response can force dnsmasq to use an arbitrarily large minimum TTL (up to 2³²−1 seconds ≈ 136 years) for NXDOMAIN caching, effectively poisoning the negative cache and causing legitimate domains to appear non-existent to downstream clients indefinitely. With a TTL of 0 the same attack can disable negative caching entirely. --- CHANGELOG | 6 +++++- src/rfc1035.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fe34575..4f23f19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,8 +20,12 @@ version 2.94 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 + Thanks to 전승훈 Seunghoon Jeon for finding this bug, it's a repeat of the problems seen in CVE-2026-4891. + + Fix OOB read in find SOA - attacker-controlled minTTL + Thanks to 전승훈 Seunghoon Jeon for finding this bug, it's + another repeat of the problems seen in CVE-2026-4891. version 2.93 diff --git a/src/rfc1035.c b/src/rfc1035.c index 015add1..040b921 100644 --- a/src/rfc1035.c +++ b/src/rfc1035.c @@ -574,7 +574,8 @@ static int find_soa(struct dns_header *header, size_t qlen, char *name, int *sub for (j = 0; j < 2; j++) /* MNAME, RNAME */ { - if (!extract_name(header, qlen, &p, daemon->workspacename, EXTR_NAME_EXTRACT, 0)) + if (!extract_name(header, qlen, &p, daemon->workspacename, EXTR_NAME_EXTRACT, 0) || + (p - psave > rdlen)) { if (cache) blockdata_free(addr.rrblock.rrdata);