PHP memory-limit crashes can leave dangling state that attackers reuse for remote code execution on mod_php
A malformed multipart upload can crash PHP's request startup and leave interpreter memory dangling. Calif Research says attackers can reuse that stale state on Apache mod_php servers to run code before any application runs.
- Affected
- Apache mod_php hash-teardown path: PHP 7.3+; Apache mod_php session-upload-progress path: PHP 5.4.0+; PHP-FPM post-startup unserialize path: Apache mod_php and PHP-FPM (exact lower bound not established by supplied evidence).
- Fixed
- patched versions released (specific version numbers not established by supplied evidence).
The finding is pre-auth remote code execution: no login is needed, and the flaw reaches arbitrary PHP scripts on the server. Calif confirmed it on WordPress, Drupal, Joomla and several other widely used applications, under default configurations.
Attackers send hundreds of empty nested multipart upload fields. Each stays small enough to slip under post_max_size, yet PHP's bookkeeping for each field builds many hash tables and buckets, pushing the request past memory_limit. PHP increments a bucket count before allocating its key, so a fatal during that allocation leaves a stale bucket.
Apache mod_php keeps the worker alive and still tears down the malformed $_POST/$_FILES table, interpreting the stale bucket as live. PHP-FPM exits the worker instead. Calif bounds this hash-teardown path to Apache mod_php running PHP 7.3 or later; the separate session-upload-progress path reaches back to PHP 5.4.0 on mod_php.
A second mod_php flaw lets session upload-progress initialize before PHP marks modules activated. If parsing fatals, session shutdown is skipped but the request heap is freed, leaving session globals pointing at dangling memory; a later upload-progress request without a file reuses them. For PHP-FPM, a post-startup fatal during session_start, session_decode, unserialize or WordPress maybe_unserialize can keep the worker alive while abandoning decoder globals, which a later request reclaims.
Calif reported both bugs to PHP, shared proof-of-concept code, and PHP confirmed it worked; patched versions were released. Specific patched version numbers are not established by the source, so administrators should apply the current patched PHP releases rather than assume a particular branch is safe.
Sources & technical scope 1 source
Affected: Apache mod_php hash-teardown path: PHP 7.3+; Apache mod_php session-upload-progress path: PHP 5.4.0+; PHP-FPM post-startup unserialize path: Apache mod_php and PHP-FPM (exact lower bound not established by supplied evidence).
Fixed: patched versions released (specific version numbers not established by supplied evidence).
Exploitation: Researcher-confirmed pre-auth RCE; PHP vendor confirmed the proof-of-concept worked; patched versions released; KEV catalog status not established by supplied evidence.
Scope & limitations: Specific patched version numbers not established by supplied evidence; whether every listed application version is vulnerable beyond the tested versions not established; KEV catalog status not established; exact lower bound for the PHP-FPM post-startup path not established by supplied evidence.
External findings belong to the credited researchers.