From 07251c056d5db8ffa320baef35e057c8d8dbc2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Wed, 6 May 2026 10:49:04 +0200 Subject: [PATCH] Fix NSEC bitmap parsing infinite loop (CVE-2026-4890) Resolves-Vulnerability: CVE-2026-4890 Resolves: RHEL-168280 (cherry picked from commit 5262d85986a0027b7fa7a5e196f1683ac05cf50f) --- dnsmasq-2.93-CVE-2026-4890.patch | 70 ++++++++++++++++++++++++++++++++ dnsmasq.spec | 3 ++ 2 files changed, 73 insertions(+) create mode 100644 dnsmasq-2.93-CVE-2026-4890.patch diff --git a/dnsmasq-2.93-CVE-2026-4890.patch b/dnsmasq-2.93-CVE-2026-4890.patch new file mode 100644 index 0000000..4ae0dcf --- /dev/null +++ b/dnsmasq-2.93-CVE-2026-4890.patch @@ -0,0 +1,70 @@ +From 09fe631edd6d95630efc11bec8c5017705e68a10 Mon Sep 17 00:00:00 2001 +From: Simon Kelley +Date: Fri, 10 Apr 2026 22:16:45 +0100 +Subject: [PATCH 2/5] Fix NSEC bitmap parsing infinite loop. CVE-2026-4890 + +Report from Royce M . + +Location: dnssec.c:1290-1306, dnssec.c:1450-1463 + +The bitmap window iteration advances by p[1] instead of p[1]+2 (missing the 2-byte window header). With bitmap_length=0, both rdlen and p are +unchanged, causing an infinite loop and dnsmasq stops responding to all queries. + +The same code accesses p[2] after only checking rdlen >= 2 without verifying p[1] >= 1, causing OOB reads at 6 locations. + +Both bugs are reachable before RRSIG validation (confirmed by the source comment at line 2125), so no valid DNSSEC signatures are needed. +--- + src/dnssec.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/src/dnssec.c b/src/dnssec.c +index ed2f53f..68f1b5d 100644 +--- a/src/dnssec.c ++++ b/src/dnssec.c +@@ -1270,10 +1270,10 @@ static int prove_non_existence_nsec(struct dns_header *header, size_t plen, unsi + packet checked to be as long as rdlen implies in prove_non_existence() */ + + /* If we can prove that there's no NS record, return that information. */ +- if (nons && rdlen >= 2 && p[0] == 0 && (p[2] & (0x80 >> T_NS)) != 0) ++ if (nons && rdlen >= 2 && p[0] == 0 && p[1] >= 1 && (p[2] & (0x80 >> T_NS)) != 0) + *nons = 0; + +- if (rdlen >= 2 && p[0] == 0) ++ if (rdlen >= 2 && p[0] == 0 && p[1] >= 1) + { + /* A CNAME answer would also be valid, so if there's a CNAME is should + have been returned. */ +@@ -1301,8 +1301,8 @@ static int prove_non_existence_nsec(struct dns_header *header, size_t plen, unsi + break; /* finished checking */ + } + +- rdlen -= p[1]; +- p += p[1]; ++ rdlen -= p[1] + 2; ++ p += p[1] + 2; + } + + return 0; +@@ -1429,7 +1429,7 @@ static int check_nsec3_coverage(struct dns_header *header, size_t plen, int dige + p += hash_len; /* skip next-domain hash */ + rdlen -= p - psave; + +- if (rdlen >= 2 && p[0] == 0) ++ if (rdlen >= 2 && p[0] == 0 && p[1] >= 1) + { + /* If we can prove that there's no NS record, return that information. */ + if (nons && (p[2] & (0x80 >> T_NS)) != 0) +@@ -1458,8 +1458,8 @@ static int check_nsec3_coverage(struct dns_header *header, size_t plen, int dige + break; /* finished checking */ + } + +- rdlen -= p[1]; +- p += p[1]; ++ rdlen -= p[1] + 2; ++ p += p[1] + 2; + } + + return 1; +-- +2.54.0 + diff --git a/dnsmasq.spec b/dnsmasq.spec index c94d617..93f0052 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -108,6 +108,7 @@ Patch47: dnsmasq-2.85-forward-retries.patch # http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=eb1fe15ca80b6bc43cd6bfdf309ec6c590aff811 Patch48: dnsmasq-2.79-cname-collision.patch Patch49: dnsmasq-2.93-CVE-2026-2291.patch +Patch50: dnsmasq-2.93-CVE-2026-4890.patch # This is workaround to nettle bug #1549190 # https://bugzilla.redhat.com/show_bug.cgi?id=1549190 @@ -190,6 +191,7 @@ server's leases. %patch47 -p1 -b .RHEL-6586 %patch48 -p1 -b .RHEL-61943 %patch49 -p1 -b .CVE-2026-2291 +%patch50 -p1 -b .CVE-2026-4890 # use /var/lib/dnsmasq instead of /var/lib/misc for file in dnsmasq.conf.example man/dnsmasq.8 man/es/dnsmasq.8 src/config.h; do @@ -291,6 +293,7 @@ install -Dpm 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/dnsmasq.conf %changelog * Tue May 05 2026 Petr Menšík - 2.79-36 - Prevent overflow in extract_name function (CVE-2026-2291) +- Prevent DoS in DNSSEC validation (CVE-2026-4890) * Mon Aug 18 2025 Tomas Korbar - 2.79-35 - Fix dnsmasq caching of intertwined CNAMES