important: Apache HTTP Server weakness with encoded question marks in backreferences (CVE-2024-38474)
A substitution encoding flaw in Apache HTTP Server's mod_rewrite allowed an attacker to execute scripts in directories that the configuration permitted but that were not directly reachable by any URL, or to disclose source of scripts meant only for CGI execution. The text does not provide reproduction details.
Originally disclosed on HackerOne
- Fixed in 37 hours
- Paid in 37 hours
- Disclosed after 10 days
Summary by the program
###important: Apache HTTP Server weakness with encoded question marks in backreferences (CVE-2024-38474)
Substitution encoding issue in mod_rewrite in Apache HTTP Server 2.4.59 and earlier allows attacker to execute scripts in directories permitted by the configuration but not directly reachable by any URL or source disclosure of scripts meant to only to be executed as CGI.
Users are recommended to upgrade to version 2.4.60, which fixes this issue.
Some RewriteRules that capture and substitute unsafely will now fail unless rewrite flag "UnsafeAllow3F" is specified.
Acknowledgements: finder: Orange Tsai (@orange_8361) from DEVCORE
Reported to security team: 2024-04-01 fixed by r1918561 in 2.4.x: 2024-07-01 Update 2.4.60 released: 2024-07-01 Affects: 2.4.0 through 2.4.59
The report
I reported this vulnerability through the official Apache HTTP Server security email on April 1, 2024, and received a fix along with a CVE number on July 1, 2024. You can check detailed information from there:
Impact
Substitution encoding issue in mod_rewrite in Apache HTTP Server 2.4.59 and earlier allows attacker to execute scripts in
directories permitted by the configuration but not directly reachable by any URL or source disclosure of scripts meant to only to be executed as CGI.
Users are recommended to upgrade to version 2.4.60, which fixes this issue.
Some RewriteRules that capture and substitute unsafely will now fail unless rewrite flag "UnsafeAllow3F" is specified.
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 an encoding issue in mod_rewrite's substitution handling of encoded question marks in backreferences, which could alter the resulting path or query in an unsafe way.
Impact
An attacker could execute scripts in directories permitted by the configuration but not directly reachable by any URL, or disclose source of scripts meant only to be executed as CGI.
What the attacker needed
Apache HTTP Server 2.4.0 through 2.4.59; mod_rewrite enabled with affected rules
The fix
The issue was fixed in Apache HTTP Server 2.4.60; some RewriteRules that capture and substitute unsafely will now fail unless the UnsafeAllow3F flag is specified.
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.
Apache HTTP Server is web server software. mod_rewrite is a module that changes URLs according to rules. A flaw in how it handled encoded question marks in backreferences let an attacker reach scripts that were not supposed to be reachable directly, potentially running them or reading their source.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.