PHP can fail to discard unread bytes from an HTTP request body before reusing a persistent PHP-FPM or LSAPI connection. In PHP-FPM, an unauthenticated attacker can make those bytes form a separate FastCGI request, bypass front-end routing and execute attacker-controlled PHP code with the privileges of the worker.
FastCGI and LSAPI connections can carry more than one request. Before accepting another request on the same connection, PHP must either consume the request body or close the connection.
Opening php://input creates a request-body stream, but PHP reads its contents lazily. During request shutdown, PHP incorrectly treated the existence of this stream as evidence that the body had already been handled and skipped the normal cleanup that discards unread input.
An attacker can combine this behaviour with a malformed multipart/form-data body that makes PHP's multipart parser stop at a predictable position. If the application then opens php://input without reading it to the end, attacker-controlled body bytes remain in the current backend request. This can occur in request frameworks that create an input stream before routing or authentication, even when the selected endpoint does not use the body.
When FCGI_KEEP_CONN is enabled, PHP-FPM preserves the connection and starts parsing another FastCGI request. The vulnerable implementation discarded its knowledge that it was still inside an FCGI_STDIN record, so a FastCGI message placed at the appropriate body offset was accepted as a new request. The front end never created or authorised this request.
The forged request controls FastCGI parameters including SCRIPT_FILENAME , REMOTE_ADDR and PHP_ADMIN_VALUE . If the attacker knows the path of an existing PHP script, they can set allow_url_include=1 and auto_prepend_file=php://input , causing the forged request's own input to be executed as PHP. The changed administrator settings can also remain active for later requests served by the same worker. The shared request-cleanup error also affects LSAPI's persistent request lifecycle, but LSAPI does not use this FastCGI parameter mechanism.
The issue was introduced with lazy php://input handling in PHP 5.6.0. The fix drains input according to whether the body was fully consumed, independently of whether a php://input stream exists. PHP-FPM additionally closes a connection instead of accepting another request when the FastCGI input record is incomplete.
Exploitation requires a front end that enables persistent backend connections and an application path that opens php://input without reading it fully. Relevant configurations include nginx with fastcgi_keep_conn on , Apache mod_proxy_fcgi with enablereuse=on , HAProxy FastCGI applications that retain backend connections, and LSAPI. Standard nginx and Apache configurations that close the FastCGI connection after each request are not affected by the demonstrated PHP-FPM attack.
For PHP-FPM, successful exploitation can execute attacker-controlled PHP code as the worker without another user's interaction or a non-default PHP configuration. It can also dispatch an existing PHP script outside the routes exposed by the front end, supply a forged client address to application access controls, or change administrator-level PHP settings for subsequent requests. The attack crosses the HTTP-to-PHP backend trust boundary using a single request. It does not require memory corruption, knowledge of memory addresses or a race condition.
For LSAPI, the shared cleanup error can leave body bytes on a persistent backend connection, desynchronising the request stream and disrupting subsequent requests. The PHP_ADMIN_VALUE chain used for PHP-FPM is not an LSAPI parameter path, so this advisory does not establish arbitrary code execution through LSAPI.
Upgrade to the fixed release for your PHP branch when it becomes available. Until then, disable backend connection reuse on the affected front end: leave nginx fastcgi_keep_conn disabled, leave Apache enablereuse disabled, or configure another FastCGI front end to close its backend connection after every request.
Reading php://input to the end before completing every request prevents the demonstrated unread-body condition, but error paths, resource exhaustion and application shutdown can make this unreliable as the sole mitigation. Do not expose PHP-FPM or LSAPI listeners directly to untrusted networks.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
