CVE-2021-45953

9.8 CRITICAL

📋 TL;DR

CVE-2021-45953 is a heap-based buffer overflow vulnerability in Dnsmasq 2.86's extract_name function that could allow remote code execution or denial of service. Systems running Dnsmasq 2.86 as a DNS server are affected. Note that the vendor disputes this represents a real vulnerability.

💻 Affected Systems

Products:
  • Dnsmasq
Versions: Version 2.86 only
Operating Systems: Linux, BSD, Other Unix-like systems
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems where Dnsmasq is configured to handle DNS queries. The vendor disputes this is a real vulnerability.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote attacker executes arbitrary code with Dnsmasq process privileges, potentially gaining full system control.

🟠

Likely Case

Denial of service causing DNS service disruption and potential system crashes.

🟢

If Mitigated

Limited impact with proper network segmentation and exploit mitigations like ASLR.

🌐 Internet-Facing: HIGH - Dnsmasq often runs on internet-facing DNS servers, making them directly accessible to attackers.
🏢 Internal Only: MEDIUM - Internal DNS servers could be targeted by compromised internal hosts.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Proof-of-concept available through OSS-Fuzz reports. Exploitation requires sending specially crafted DNS queries.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Version 2.87 and later

Vendor Advisory: https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2022q1/016162.html

Restart Required: Yes

Instructions:

1. Download Dnsmasq 2.87 or later from official repository. 2. Stop Dnsmasq service. 3. Install new version. 4. Restart Dnsmasq service.

🔧 Temporary Workarounds

Network filtering

linux

Block external DNS queries to Dnsmasq using firewall rules

iptables -A INPUT -p udp --dport 53 -j DROP
iptables -A INPUT -p tcp --dport 53 -j DROP

Disable DNS functionality

linux

Configure Dnsmasq to only provide DHCP services if DNS is not required

Edit /etc/dnsmasq.conf and set 'port=0'

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate Dnsmasq servers
  • Enable exploit mitigations like ASLR and DEP on the host system

🔍 How to Verify

Check if Vulnerable:

Check Dnsmasq version: dnsmasq --version | head -1

Check Version:

dnsmasq --version | head -1

Verify Fix Applied:

Verify version is 2.87 or higher: dnsmasq --version | grep -q 'version 2\.8[7-9]\|version 2\.[9-9]' && echo 'Patched'

📡 Detection & Monitoring

Log Indicators:

  • Multiple malformed DNS query errors
  • Dnsmasq process crashes or restarts

Network Indicators:

  • Unusual DNS query patterns with malformed names
  • Traffic spikes to port 53

SIEM Query:

source="dnsmasq" AND (error OR crash OR "malformed")

🔗 References

📤 Share & Export