Fix use-after-free in relay_upstream6(). CVE-2026-133730

relay_upstream6() takes a pointer to the Relay-forward header at the
start of the output packet, then adds the client link-layer address
and relay message options, and then writes the link-address into the
header through that pointer, once for each relay. Adding the options
makes expand_buf() move the packet buffer whenever the relayed message
doesn't fit the buffer as it is, and the buffer starts out at 548
bytes. The link-address is then written into memory which has been
freed, and the packet goes out with an empty link-address.

One DHCPv6 message of about 500 bytes or more arriving on an interface
with --dhcp-relay configured is enough for that. With a normal build
it takes a few messages of growing size to crash dnsmasq: the write
lands on the heap's own bookkeeping in the freed block.

Up to 2.86 the link-address was written before the options were
added. Commit 7fbf1cc ("Improve the performance of DHCP relay.")
moved it into the loop over the relays, so 2.87 is the first release
with the problem.

Find the header again once the packet is complete.

Credit to Akin Yilmaz (DecompilerAI) and, independently,
Georgi Steffenhagen <georgisteffenhagen@servertec.net> for finding this.
This commit is contained in:
Georgi Steffenhagen authored and Simon Kelley committed 2026-11-29 11:37:04 +00:00
1 parent e5731e9928
commit 9785e2ec41
2 files changed
+7

No files matched your search

+3
View File
@@ -13,6 +13,9 @@ version 2.94
for spotting and reporting this. A crafted reply can crash dnsmasq. for spotting and reporting this. A crafted reply can crash dnsmasq.
CNVD-C-2026-590208 applies. CNVD-C-2026-590208 applies.
Fix heap OOB write in relay_upstream6() Thanks to
Akin Yilma (DecompilerAI) and Georgi Steffenhagen for spotting this.
CVE-2026-133730 appiles.
version 2.93 version 2.93
Fix a corner-case in DNSSEC validation with wildcards. If we have Fix a corner-case in DNSSEC validation with wildcards. If we have
+4
View File
@@ -2218,6 +2218,10 @@ int relay_upstream6(int iface_index, ssize_t sz,
put_opt6(inbuff, sz); put_opt6(inbuff, sz);
end_opt6(o); end_opt6(o);
/* Adding the options above may have moved the packet buffer,
so find the header again before writing to it below. */
header = daemon->outpacket.iov_base;
for (; relay; relay = relay->next) for (; relay; relay = relay->next)
if (relay->iface_index != 0 && relay->iface_index == iface_index) if (relay->iface_index != 0 && relay->iface_index == iface_index)
{ {