Apache mod_rewrite: an exploited flaw in common rewrite rules
CVE-2024-38475 is a flaw in how Apache mod_rewrite escapes its output. It was fixed in July 2024, but CISA added it to its list of actively exploited vulnerabilities in May 2025. Servers that still run Apache 2.4.59 or older, with certain rewrite rules, remain exposed.
- CVE
CVE-2024-38475 - SeverityCVSS 9.1 Critical
- ProductApache HTTP Server
- ExploitationActively exploited (CISA KEV)
What happened
The flaw came out of Orange Tsai's "Confusion Attacks" research in 2024. mod_rewrite did not escape its output correctly in some rules. As a result, a URL could be mapped to a place on disk that the server may serve, but that was never meant to be reachable from the web.
That can expose source code or configuration files, and in some setups it can lead to code execution. NVD rates CVE-2024-38475 9.1 under CVSS 3.1; Apache rates it Important. CISA added it to its Known Exploited Vulnerabilities catalog on 1 May 2025. Whether ransomware groups use it is not known.
Who is affected
| Apache httpd | Vulnerable | Recommended version |
|---|---|---|
| 2.4.0 to 2.4.59 | Yes, with an affected rule | 2.4.71 or later |
| 2.4.60 to 2.4.70 | Fixed for this CVE | 2.4.71 or later, for later fixes |
Not every rewrite rule is affected. The risk lies in a RewriteRule in server or virtual-host configuration whose substitution starts with a backreference or a variable, such as $1 or %{...}. Rules like that are common in older configurations and copied templates.
How to check your server
Check the version, then search the configuration for rules whose target starts with a backreference or variable.
apachectl -v # or: httpd -v
grep -RnE 'RewriteRule\s+\S+\s+[$%]' /etc/apache2 /etc/httpdDebian, Ubuntu and Red Hat often backport fixes without changing the version number. A server that reports 2.4.57 may already have the fix. Check your distribution's security tracker for CVE-2024-38475.
How to fix it
- Upgrade to Apache httpd 2.4.71, or to the latest package release from your distribution. 2.4.60 was the first fixed version, but later releases fix more flaws.
- Restart Apache and confirm the version with
apachectl -v. - Test your site after the upgrade. Some unsafe rules stop working on purpose and return errors.
- Review each rule that broke. Rewrite it so it no longer maps to an unchecked path where you can.
- Add the
UnsafePrefixStatflag only to rules you have reviewed and know to be safe. Do not add it everywhere to make errors go away.
What to look for
If a vulnerable server had an affected rule, check the access log for unusual requests that returned files outside the normal site paths, such as configuration files or script source. If source or config files may have been read, change the passwords and keys they contained. A Linux server audit reviews Apache rewrite rules, patch level and signs of compromise.
Questions
Do rules in .htaccess files count?
The vulnerable case named in the advisory is a rule in server or virtual-host configuration. Upgrading fixes the flaw for all contexts, so upgrade either way.
My site broke after the upgrade. Should I downgrade?
No. The fix blocks rules that are unsafe. Review the rule that broke and add UnsafePrefixStat only if you are sure it is safe.
This is from 2024. Why does it matter now?
It is on the CISA list of exploited vulnerabilities, and many servers still run old Apache versions. Old flaws stay popular with attackers because they keep working.
This article is written for defenders and contains no exploit code. It reflects the vendor advisories on the date above; always check the vendor advisory for the latest fixed versions.
Not sure whether you are affected?
We check your servers and applications for this vulnerability and others like it, and give you a clear report with fixes.