Apache HTTP Server mod_rewrite/mod_setenvif/mod_proxy_fcgi ap_expr Local File Read — CVE-2026-24072
by EricRHancock-coder · 2026-07-05
- Severity
- Medium
- CVE
- CVE-2026-24072
- Category
- web
- Affected product
- Apache HTTP Server (httpd)
- Affected versions
- <= 2.4.66 (fixed in 2.4.67)
- Disclosed
- 2026-07-05
- Patch status
- patched
Tags
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-05 |
| Author / Researcher | EricRHancock-coder |
| CVE / Advisory | CVE-2026-24072 |
| Category | web |
| Severity | Medium |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | apache-httpd, mod_rewrite, ap_expr, htaccess, local-privilege-escalation, arbitrary-file-read, information-disclosure, cwe-668 |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Apache HTTP Server (httpd) |
| Versions Affected | <= 2.4.66 (fixed in 2.4.67) |
| Language / Platform | C (Apache module source/patches), .htaccess PoC expressions |
| Authentication Required | Local-only (requires ability to write a .htaccess file) |
| Network Access Required | No |
Summary
Apache HTTP Server’s ap_expr expression evaluation engine exposes filesystem-introspection functions (file(), filesize(), and tests like -f, -d, -e, -s, -L, -h, -x) that are meant to be restricted when expressions are parsed from a .htaccess file rather than the main server configuration. In versions up to and including 2.4.66, the modules mod_rewrite (RewriteCond expr=...), mod_setenvif (SetEnvIfExpr), and mod_proxy_fcgi (backend-type condition expressions) failed to pass the AP_EXPR_FLAG_RESTRICTED flag when parsing expressions in .htaccess (per-directory) context. This lets any local user who can place a .htaccess file in a directory served by Apache read or probe arbitrary files with the privileges of the httpd worker process, even though .htaccess authors are normally sandboxed away from filesystem access outside their directory. The repository is a technical writeup with the three module patch diffs, vulnerable/fixed Apache source trees, and a Dockerized test lab with a sentinel file to demonstrate the vulnerable vs. patched behavior.
Vulnerability Details
Root Cause
mod_rewrite, mod_setenvif, and mod_proxy_fcgi parse ap_expr expressions without setting AP_EXPR_FLAG_RESTRICTED when the parsing context is .htaccess (detected via the internal convention cmd->pool == cmd->temp_pool), allowing filesystem-reading expression functions to run unrestricted in a context meant to be sandboxed.
Attack Vector
- Obtain the ability to write a
.htaccessfile in any directory served by a vulnerable Apache HTTP Server (e.g., via shared hosting, an upload directory, or a compromised low-privilege web account). - Place directives such as
RewriteCond expr "%{expr:file('/etc/shadow')}"orRewriteCond expr "-f /etc/shadow"in the.htaccessfile. - Request any URL under that directory, causing Apache to evaluate the expression with
httpd-user privileges. - Observe the result via a triggered rewrite/redirect, response header, or (in verbose/debug configurations) the error log, to infer file existence, size, or full contents.
- Repeat with different paths/functions to enumerate or exfiltrate sensitive files readable by the
httpduser.
Impact
A local user restricted to .htaccess-level configuration can read or probe arbitrary files accessible to the Apache worker process, bypassing the intended per-directory sandbox and potentially exposing credentials, other tenants’ files, or system configuration on shared/multi-tenant hosting.
Environment / Lab Setup
Target: Apache HTTP Server <= 2.4.66 (vulnerable) vs. 2.4.67 (patched)
Attacker: Local .htaccess write access; Docker + make for the included test lab
Proof of Concept
PoC Script
See
mod_rewrite.diff,mod_setenvif.diff,mod_proxy_fcgi.diff,examples/exploit.htaccess,examples/safe-expressions.htaccess, andCVE-2026-24072-analysis.mdin this folder.
| |
examples/exploit.htaccess demonstrates the vulnerable behavior directly: RewriteCond expr directives using -f/-d/-e file-existence tests and file()/filesize() content/size probes against sensitive paths like /etc/passwd, /etc/shadow, and application config files. The three .diff files show the upstream fix (adding the AP_EXPR_FLAG_RESTRICTED flag in .htaccess context), and the Docker-based lab lets a reviewer flip between the vulnerable and patched module builds to confirm the sentinel file (/opt/sentinel/secret.txt) is readable only in the vulnerable configuration.
Detection & Indicators of Compromise
"...ap_expr: ... not available in restricted context..."
grep -R "expr:file(" /var/www -l --include=".htaccess"
Signs of compromise:
.htaccessfiles in tenant/upload directories containingRewriteCond expr,SetEnvIfExpr, or proxy backend-type expressions referencingfile(),filesize(), or filesystem test operators against paths outside the web root.- Apache access/error logs showing repeated requests to a directory immediately after an unfamiliar
.htaccessfile is created or modified there. - Unexplained knowledge of file existence/size/contents outside a tenant’s directory surfacing in rewrite redirects or response behavior.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade to Apache HTTP Server 2.4.67 or later, which passes AP_EXPR_FLAG_RESTRICTED for ap_expr parsing in .htaccess context across mod_rewrite, mod_setenvif, and mod_proxy_fcgi. |
| Interim mitigation | Disable AllowOverride (or restrict it to only necessary directive types) for untrusted/shared-hosting directories so users cannot introduce arbitrary RewriteCond expr/SetEnvIfExpr directives via .htaccess. |
References
Notes
Mirrored from https://github.com/EricRHancock-coder/CVE-2026-24072-Analysis on 2026-07-05. Only the patch diffs, example .htaccess PoC files, and the technical analysis document were mirrored; the full vulnerable/patched Apache/APR source trees and Docker test-lab scaffolding from the original repository were omitted as they are the upstream project’s own build trees rather than PoC code.