PHP2Shell PHP-FPM session memory exhaustion with session decode failure or FPM worker segfault on the same host and service

This rule is part of a beta feature. To learn more, contact Support.

Goal

Detects PHP2Shell (CVE-2026-109618/109619) exploitation stages in PHP and PHP-FPM logs. A pre-script PHP memory exhaustion accompanied by a session subsystem error, a session decode failure, or a PHP-FPM worker segfault on the same host and service signals an exploit attempt.

Strategy

This rule monitors PHP error logs and PHP-FPM master logs for the stages of PHP2Shell, a memory-safety vulnerability in PHP’s multipart and session upload-progress handling that leads to remote code execution.

  • In the arm stage, a large multipart POST exhausts memory_limit before any script runs, so PHP logs Allowed memory size of ... exhausted with the location in Unknown on line 0 instead of a script path. A Failed to decode session object warning often follows.
  • In the fire stage, a second request crashes the worker, and the PHP-FPM master logs child N exited on signal 11 (SIGSEGV). Ordinary out-of-memory errors name the script and line that ran out of memory, so a pre-script memory failure is rare on its own.

The rule raises signals with different levels of severity, depending on the situation:

  • Critical: The memory failure occurs on the same host and service, within five minutes, as a PHP session subsystem error that was raised before any script ran. The error could be a failure to read or write session data, or a rejected session ID, each ending in Unknown on line 0. This pairing matches crash-free exploit chains that keep the worker alive and never corrupt cross-request session state, so they produce neither a worker segfault nor a session decode failure.
  • High: The memory failure and the session decode failure occur together.
  • Medium: The memory failure and a worker segfault occur together.

PHP-FPM crash lines that arrive without a host value cannot be correlated, so environments should tag PHP-FPM logs with the originating host.

Triage & Response

  • Examine the memory failure and the exited on signal 11 lines for {{service}} on {{host}}, and note the PHP-FPM pool and child process ID involved.
  • Review the access logs of the web server in front of PHP-FPM on {{host}} for large multipart POST requests around the signal, and identify the client that sent them.
  • Determine whether the memory failure came from a legitimate oversized upload or a recurring memory-pressure crash loop by checking how often the pair repeats and whether {{service}} normally handles large uploads.
  • Review any PHP session subsystem errors (Failed to read session data, Failed to write session data, or Session ID is too long or contains illegal characters) for {{service}}, and distinguish a misconfigured session.save_path, which raises these warnings on their own, from warnings that appear only in the same request as the memory failure.
  • Check whether PHP-FPM restarted workers repeatedly around the signal, and correlate the crash times with requests from the same client.
  • Identify the PHP version for {{service}} and verify whether it includes the fix (8.5.12, 8.4.27, 8.3.36 or 8.2.35).
  • Inspect {{host}} for signs of successful exploitation, such as child processes spawned by PHP-FPM workers, in-memory executables, new files owned by the web server user, or unexpected outbound connections.