SecRule Bypass
The cookie string parser in libModSecurity 3.0.0 to 3.0.3 mishandled cookie values containing an equals sign, so a rule checking a cookie value could be bypassed, and a cookie header beginning with an equals sign caused an out-of-range error that killed the Nginx worker process. An attacker could hide malicious content from the firewall or repeatedly crash workers to deny service.
secjuice.com
Published on secjuice.com
In October 2019, Ervin Hegedus and I have discovered two vulnerabilities on the open source web application firewall "libModSecurity"(CVE-2019-19886 from version 3.0.0 to 3.0.3) that could lead to a SecRule bypass and a denial of Service. In this article, I'll describe both vulnerabilities with a PoC on Nginx.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the cookie parser split on every equals sign instead of only the first one and did not handle a cookie string starting with an equals sign, causing an out-of-range error.
Impact
A crafted cookie could hide SQL injection or cross-site scripting payloads from ModSecurity rules, and repeated requests could kill Nginx workers and deny service to the site.
What the attacker needed
Nginx with libModSecurity 3.0.0-3.0.3; ability to send crafted Cookie headers
The fix
The parser was patched so that cookie values containing equals signs are handled correctly and malformed cookie strings no longer cause an out-of-range error.
How it was found
- Build a test setup with Nginx and libModSecurity 3.0.3.
- Send a request whose Cookie header starts with an equals sign followed by a name.
- Observe that no response comes back and the Nginx error log shows an out-of-range error from the killed worker.
- Repeat the requests continuously to kill respawning workers and keep the site unavailable.
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 write-up has not been written yet. The Original tab links to the source.
A web application firewall (WAF) inspects incoming requests and blocks ones that look malicious. ModSecurity is a popular open-source WAF, and its cookie parser split the cookie text incorrectly, so part of a value was never checked. A second bug made the parser crash on a malformed cookie, and because the crash happened inside the web server's worker process, sending such requests repeatedly could take the site offline.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.