dnsmasq EDNS Client Subnet (ECS) Response Validation Bypass (CVE-2026-4893)
by lottiedeyan · 2026-07-05
- Severity
- Medium
- CVE
- CVE-2026-4893
- Category
- network
- Affected product
- dnsmasq (DNS forwarder/cache)
- Affected versions
- Not specified in source (repo only names the flaw class: "ECS validation and buffer overflow flaws")
- Disclosed
- 2026-07-05
- Patch status
- unpatched
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-07 |
| Author / Researcher | lottiedeyan |
| CVE / Advisory | CVE-2026-4893 |
| Category | network |
| Severity | Medium |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | dnsmasq, dns, edns, ecs, rfc7871, cache-poisoning, spoofing, udp |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | dnsmasq (DNS forwarder/cache) |
| Versions Affected | Not specified in source (repo only names the flaw class: “ECS validation and buffer overflow flaws”) |
| Language / Platform | C (dnsmasq daemon); PoC written in Python 3 |
| Authentication Required | No |
| Network Access Required | Yes (must be positioned to answer, or spoof answers to, dnsmasq’s upstream queries) |
Summary
This PoC demonstrates that dnsmasq, when configured with EDNS Client Subnet (ECS, RFC 7871) via add-subnet, will accept an upstream DNS response carrying an ECS option whose subnet does not match the subnet dnsmasq originally sent in the query. The included exp.py acts as a fake upstream DNS server: it waits for dnsmasq’s query for a specific test name, then replies with a forged answer (1.2.3.4) wrapped in an EDNS0 OPT record advertising an unrelated/mismatched ECS subnet (127.18.0.0/24). A companion self-test then queries dnsmasq directly and checks whether dnsmasq returned the forged IP, which the author interprets as evidence dnsmasq did not validate/discard the mismatched-ECS reply as it should.
Vulnerability Details
Root Cause
Per the repo’s referenced write-up (a Medium article titled “reproduction journal: dnsmasq ECS validation and buffer overflow flaws”), dnsmasq does not properly validate that the ECS subnet returned in an upstream response corresponds to the subnet it requested for a given query. If dnsmasq accepts and caches/forwards such a mismatched response without discarding it, this weakens the assurance that ECS-tagged answers actually apply to the client subnet they claim to, which can facilitate response injection/cache poisoning style attacks against dnsmasq’s DNS resolution results.
Attack Vector
- Attacker controls (or can spoof packets from) the address dnsmasq is configured to use as its upstream
server=(in the PoC, dnsmasq points at127.0.0.1#5354where the fake server listens). - Attacker’s fake DNS server waits for dnsmasq to forward a query for the target name (
trigger.evil.comin the PoC). - Attacker crafts a DNS response for that query containing an attacker-chosen answer IP and an EDNS0 OPT record with an ECS option whose subnet (
127.18.0.0/24) intentionally does not match the subnet dnsmasq sent (or would be expected to send) in its own query. - dnsmasq accepts the response despite the ECS mismatch; the PoC’s self-test then queries dnsmasq for the same name and checks whether it returns the forged IP, confirming the mismatched reply was accepted.
Impact
An attacker able to answer (or spoof answers to) dnsmasq’s upstream queries can inject forged DNS answers under ECS-enabled configurations without the ECS-subnet consistency check dnsmasq’s add-subnet feature is expected to provide, potentially enabling DNS response/cache poisoning against clients relying on the dnsmasq resolver.
Environment / Lab Setup
Target: dnsmasq configured with add-subnet, listening on port 5353, forwarding to a controlled upstream at 127.0.0.1#5354 (see dnsmasq.conf)
Attacker: Python 3 script (exp.py) bound as the fake upstream DNS server on 127.0.0.1:5354
Proof of Concept
PoC Script
See
exp.py(fake upstream DNS server / spoofed-ECS responder) anddnsmasq.conf(test dnsmasq configuration) in this folder. Seereadme.txtfor the original reproduction steps.
| |
The script starts a UDP listener acting as dnsmasq’s upstream resolver, waits for a query for trigger.evil.com, and replies with a forged A record plus a deliberately mismatched ECS option. It concurrently runs a self-test that queries dnsmasq directly on port 5353 and reports whether dnsmasq returned the forged 1.2.3.4 answer, which indicates the mismatched ECS reply was accepted rather than discarded.
Detection & Indicators of Compromise
grep -i 'trigger.evil.com' /var/log/syslog
tcpdump -i any -n udp port 5354 -X
Signs of compromise:
- DNS answers from an upstream resolver containing an ECS option subnet inconsistent with the subnet dnsmasq queried with
- Unexpected/forged A records being served by dnsmasq for domains not actually pointing to that IP
- dnsmasq upstream traffic to unexpected or unauthorized resolver addresses
Remediation
| Action | Detail |
|---|---|
| Primary fix | Update dnsmasq to a version that enforces ECS-subnet/response consistency validation; monitor the dnsmasq project’s advisories for a fix tied to CVE-2026-4893 |
| Interim mitigation | Restrict/authenticate upstream DNS servers dnsmasq forwards to (e.g. via TLS/DoT where supported, or strict network ACLs), and disable add-subnet/ECS forwarding if not required |
References
Notes
Mirrored from https://github.com/lottiedeyan/CVE20264893poc on 2026-07-05.
| |