CVE-2024-38474·Apache vulnerability
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.
- Severity
- critical
- Software
- Apache
- Fixed in
- 2.4.60
- Published
- 2024-07-01
Affected versions
From: 2.4.0
Until: 2.4.60
Fixed in: 2.4.60
How to fix this CVE
Upgrade Apache HTTP Server to version 2.4.60 or later to resolve a critical mod_rewrite substitution encoding vulnerability that could allow unauthorized script execution. If you use RewriteRules with unsafe character substitution, test your configuration after upgrading as the patch introduces stricter validation requiring the UnsafeAllow3F flag for previously permissive rules. Perform this update on all systems running Apache 2.4.0 through 2.4.59 as soon as possible given the critical severity.
sudo dnf update httpdDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST|GET requests containing URL-encoded or hex-encoded queries (\?|%3F) targeting paths outside web root directories, followed by successful execution indicated by 200 status codes and script output in response bodies instead of 403/404 errorsWAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement strict URL validation rules that block requests with suspicious percent-encoded or double-encoded query strings targeting script extensions (.php, .cgi, .py, .sh) on non-public directories; block requests attempting path traversal sequences like ../ or encoded variants; enforce whitelist-based RewriteRule filtering at the WAF layer until systems are patchedHow to check if you are affected
- Check installed Apache version: apache2ctl -v (Debian/Ubuntu) or httpd -v (RHEL/CentOS)
- Review mod_rewrite configuration for unsafe RewriteRules: grep -r 'RewriteRule' /etc/apache2/conf-enabled/ or /etc/httpd/conf.d/
- Search access logs for suspicious patterns targeting non-existent URLs followed by script execution: grep -E '(\?|%3F)' /var/log/apache2/access.log | grep -E '\.(php|cgi|py|sh)'
- Verify patch installation by confirming version is 2.4.60 or higher: apache2ctl -v | grep -oP '\d+\.\d+\.\d+'
FAQ
What is CVE-2024-38474?
CVE-2024-38474 is a critical vulnerability in Apache mod_rewrite that improperly handles character substitution in rewrite rules, potentially allowing attackers to bypass URL restrictions and execute scripts that should not be directly accessible from the web.
Is CVE-2024-38474 being actively exploited?
No, this vulnerability is not listed on the CISA Known Exploited Vulnerabilities (KEV) catalog and no public exploits have been disclosed as of now, though the critical CVSS 9.8 score warrants immediate patching.
What versions of Apache are affected by CVE-2024-38474?
Apache HTTP Server versions 2.4.0 through 2.4.59 are vulnerable; version 2.4.60 and all later releases contain the fix.
How do I check if my server is vulnerable to CVE-2024-38474?
Run 'apache2ctl -v' or 'httpd -v' and note the version number; if it reports 2.4.59 or earlier, your server is vulnerable and requires immediate upgrade.
Does Defensia detect CVE-2024-38474?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If Apache is installed on a monitored server, CVE-2024-38474 will appear in your dashboard with remediation steps.
Related Apache CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-38474. Free for 1 server.
Get started free