critical CVSS 9.1 Actively exploited

CVE-2024-38475·Apache vulnerability

Improper escaping of output in mod_rewrite in Apache HTTP Server 2.4.59 and earlier allows an attacker to map URLs to filesystem locations that are permitted to be served by the server but are not intentionally/directly reachable by any URL, resulting in code execution or source code disclosure. Substitutions in server context that use a backreferences or variables as the first segment of the substitution are affected.  Some unsafe RewiteRules will be broken by this change and the rewrite flag "UnsafePrefixStat" can be used to opt back in once ensuring the substitution is appropriately constrained.

Severity
critical
Software
Apache
Fixed in
10.2.1.14-75sv
Published
2024-07-01

Affected versions

From: 2.4.0

Until: 10.2.1.14-75sv

Fixed in: 10.2.1.14-75sv

How to fix this CVE

Upgrade Apache HTTP Server to version 2.4.60 or later immediately. If immediate upgrade is not possible, audit all RewriteRule directives in server context for backreferences or variables in the first segment of the substitution target.

sudo apt update && sudo apt install --only-upgrade apache2
# Verify: apache2 -v (should show 2.4.60+)
# Review rewrite rules:
grep -r RewriteRule /etc/apache2/sites-enabled/
sudo systemctl restart apache2

Defensia detects this vulnerability

What an exploitation attempt looks like

Sample log line indicative of exploitation attempts:

GET /rewrite-target/%2e%2e/%2e%2e/etc/passwd HTTP/1.1

Attackers craft URLs that exploit backreference substitution in RewriteRule to traverse outside the intended document root. Improper output escaping allows the resolved path to reference files outside the web root.

WAF mitigation (if patching is not yet possible)

Add this rule to your WAF to block exploitation attempts while you schedule the patch.

SecRule REQUEST_URI "(?:%2e%2e|%252e%252e|\.\.)" "id:20243847,phase:1,deny,status:403,msg:'CVE-2024-38475 path traversal via mod_rewrite',severity:CRITICAL"

How to check if you are affected

  1. Check Apache version: apache2 -v or httpd -v — vulnerable if < 2.4.60
  2. Audit RewriteRule directives using backreferences: grep -rn 'RewriteRule' /etc/apache2/ /etc/httpd/ 2>/dev/null
  3. Check Apache access logs for path traversal: grep -iE '%2e%2e|%252e' /var/log/apache2/access.log
  4. Verify mod_rewrite is loaded: apache2ctl -M | grep rewrite
  5. Check error logs for unexpected file access: grep 'File does not exist' /var/log/apache2/error.log | grep -v 'favicon'

Indicators of compromise

  • HTTP requests with encoded dot-dot sequences (%2e%2e) targeting rewrite endpoints
  • Unexpected file reads in Apache error logs from outside document root
  • Access to source files (.php, .conf) that should not be directly served
  • Requests containing double-encoded path traversal (%252e%252e)

FAQ

Which Apache versions are affected?

All Apache HTTP Server versions from 2.4.0 through 2.4.59 are affected when mod_rewrite is enabled with backreference substitutions in server context. Version 2.4.60 contains the fix.

Is mod_rewrite enabled by default?

On most Linux distributions, mod_rewrite is installed but not always enabled by default. However, it is extremely common in production — virtually all WordPress, Laravel, and framework-based sites enable it.

Does this affect Apache behind a reverse proxy?

If the reverse proxy passes the raw URL through to Apache, yes. Some reverse proxies normalize URLs and strip traversal sequences, which may provide incidental protection, but do not rely on this.

Can this lead to remote code execution?

Yes. If the attacker can map to a CGI script, PHP file, or other executable resource outside the intended web root, they can achieve code execution. Source code disclosure is the more common impact, but RCE is possible depending on server configuration.

What is the UnsafePrefixStat flag?

Apache 2.4.60 introduced this rewrite flag to allow administrators to opt back into the old (vulnerable) behavior for specific rules. Using this flag re-introduces the vulnerability — only use it after carefully auditing the substitution target.

Related Apache CVEs

CVE-2024-38476CVSS 9.8Vulnerability in core of Apache HTTP Server 2.4.59 and earlier are vulnerably to information disclosure, SSRF or local script execution via backend applications whose response headers are malicious or exploitable. Users are recommended to upgrade to version 2.4.60, which fixes this issue.
CVE-2024-38474CVSS 9.8Substitution 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.
CVE-2025-23048CVSS 9.1In some mod_ssl configurations on Apache HTTP Server 2.4.35 through to 2.4.63, an access control bypass by trusted clients is possible using TLS 1.3 session resumption. Configurations are affected when mod_ssl is configured for multiple virtual hosts, with each restricted to a different set of trusted client certificates (for example with a different SSLCACertificateFile/Path setting). In such a case, a client trusted to access one virtual host may be able to access another virtual host, if SSLStrictSNIVHostCheck is not enabled in either virtual host.
CVE-2025-58098CVSS 8.3Apache HTTP Server 2.4.65 and earlier with Server Side Includes (SSI) enabled and mod_cgid (but not mod_cgi) passes the shell-escaped query string to #exec cmd="..." directives. This issue affects Apache HTTP Server before 2.4.66. Users are recommended to upgrade to version 2.4.66, which fixes the issue.
CVE-2024-38473CVSS 8.1Encoding problem in mod_proxy in Apache HTTP Server 2.4.59 and earlier allows request URLs with incorrect encoding to be sent to backend services, potentially bypassing authentication via crafted requests. Users are recommended to upgrade to version 2.4.60, which fixes this issue.

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-38475. Free for 1 server.

Get started free