If your Apache config leans on RewriteRule, this older bug is worth a quick check.

At a glance

  • CVE: CVE-2024-38474, one of a batch of Apache bugs Orange Tsai of DEVCORE reported in 2024 and later presented at Black Hat USA 2024 as “Confusion Attacks”.
  • Severity: 9.8 (Critical) at NVD. Apache itself rates it “important”, and CISA’s score is lower, at 8.1 (High).
  • Affected: Apache HTTP Server 2.4.0 through 2.4.59. NVD also lists NetApp Clustered Data ONTAP 9.0.
  • Known exploited: Not on CISA’s KEV list. (Its mod_rewrite sibling, CVE-2024-38475, is.)

What’s going on

mod_rewrite is the module behind most RewriteRule lines: pretty URLs, front-controller routing, redirects. A lot of those rules capture part of the request URL and drop it into a new path or query string. In Apache 2.4.59 and earlier, an encoded question mark (%3F) inside that captured bit wasn’t handled safely. Once it’s substituted back in, it can act like a real ?, so everything after it gets treated as a query string and the path is cut short.

An attacker can use that truncation to land on files your config lets Apache serve but that no URL is meant to reach directly. Apache says that means two things: running scripts in directories the config allows but no URL points to, and leaking the source code of scripts that were only ever meant to run as CGI.

Who should care? Anyone running Apache 2.4.59 or older with rewrite rules that capture part of the URL and substitute it back in. That covers a lot of everyday setups, so it’s simplest to assume you’re in scope until you’ve upgraded.

Timeline

  • Reported to Apache: 2024-04-01
  • Disclosed and patched: 2024-07-01 (Apache HTTP Server 2.4.60)
  • Researcher’s write-up: 2024-08-09

== UPDATE ==

Good news: this has been fixed for a long time, so it’s mostly a matter of making sure nothing slipped through.

  • Patch available: Yep, since July 2024.
  • Fixed in: Apache HTTP Server 2.4.60. That said, aim for 2.4.62 or later. Another fix in 2.4.60 (for CVE-2024-38476) caused a source-code-disclosure regression that took 2.4.61 and 2.4.62 to sort out (CVE-2024-39884 and CVE-2024-40725). The newest release on Apache’s page is 2.4.71, from 2026-11-11.
  • How to apply: Most people get Apache from their distro, so update the package: sudo apt update && sudo apt install --only-upgrade apache2 on Debian/Ubuntu, or sudo dnf upgrade httpd on RHEL, Alma, Rocky or Fedora. Then check the config with apachectl configtest and restart Apache. Distros backport fixes, so your version string may still read lower than 2.4.60. Check your distro’s security tracker for CVE-2024-38474 rather than going by the number. If you build from source, grab the current 2.4.x release from httpd.apache.org.
  • Heads-up after upgrading: some rules that capture and re-substitute unsafely will now be refused. If a rule breaks and you’re sure a user-supplied %3F can’t be abused there, you can add the UnsafeAllow3F flag to that one rule (for example [L,QSA,UnsafeAllow3F]). Apache’s docs say to use it only where you’re certain it’s safe, and to restructure URLs to avoid encoded question marks where you can.
  • If you can’t patch yet: Apache doesn’t offer a workaround other than upgrading. In the meantime, review rewrite rules that capture part of the URL and substitute it into a path, and tighten them where you can. If your app never needs %3F in the path, rejecting it at your proxy or WAF can reduce the risk, but it’s not a full fix.

References