1-byte heap buffer overflow in DNS resolver
A one-byte heap buffer overflow exists in nginx's DNS resolver when processing a specially crafted DNS response. An attacker who can forge UDP packets from the DNS server could crash the worker process or potentially achieve arbitrary code execution.
Originally disclosed on HackerOne
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 3 months
Official announcement: http://mailman.nginx.org/pipermail/nginx-announce/2021/000300.html
A security issue in nginx resolver was identified, which might allow an attacker to cause 1-byte memory overwrite by using a specially crafted DNS response, resulting in worker process crash or, potentially, in arbitrary code execution (CVE-2021-23017).
The issue only affects nginx if the "resolver" directive is used in the configuration file. Further, the attack is only possible if an attacker is able to forge UDP packets from the DNS server.
The issue affects nginx 0.6.18 - 1.20.0. The issue is fixed in nginx 1.21.0, 1.20.1.
Patch for the issue can be found here:
http://nginx.org/download/patch.2021.resolver.txt
Thanks to Luis Merino, Markus Vervier, Eric Sesterhenn, X41 D-Sec GmbH.
Impact
Crash or, potentially, arbitrary code execution.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a missing bounds check when copying a DNS response field into a fixed-size heap buffer, allowing a one-byte overwrite.
Impact
The attacker could crash the nginx worker process or potentially execute arbitrary code, but only if the resolver directive is used and the attacker can forge UDP packets from the DNS server.
What the attacker needed
Resolver directive used in config; attacker can forge UDP packets from DNS server
The fix
The issue was fixed in nginx 1.21.0 and 1.20.1.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
nginx is a web server that can look up domain names using DNS. A bug in how it handles DNS replies lets someone who can fake those replies write one byte past the end of a memory buffer. This can crash the server or, in rare cases, let the attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.