---
title: >-
  PHP2Shell memory exhaustion with worker crash or session decode failure on an
  Apache host
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > PHP2Shell memory exhaustion with worker
  crash or session decode failure on an Apache host
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# PHP2Shell memory exhaustion with worker crash or session decode failure on an Apache host

{% alert level="danger" %}
This rule is part of a beta feature. To learn more, [contact Support](https://docs.datadoghq.com/help/).
{% /alert %}
Classification:attackTactic:[TA0001-initial-access](https://attack.mitre.org/tactics/TA0001)Technique:[T1190-exploit-public-facing-application](https://attack.mitre.org/techniques/T1190) 
## Goal{% #goal %}

Detects PHP2Shell (CVE-2026-109618/109619) exploitation stages on an Apache host running `mod_php` or `proxy_fcgi`. A pre-script PHP memory exhaustion accompanied by a session subsystem error, a session decode failure, or an Apache worker crash on the same host signals an exploit attempt.

## Strategy{% #strategy %}

This rule monitors Apache and PHP error 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. With `mod_php`, the message lands in the Apache error log, and with `proxy_fcgi` it lands in the PHP-FPM log. A `Failed to decode session object` warning often follows.
- In the **fire** stage, a second request crashes the PHP worker: `proxy_fcgi` logs `AH01075` with `Connection reset by peer`, and `mod_php` logs a child exiting with `exit signal Segmentation fault`.

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

- `Critical`: The memory failure occurs on the same host, within five minutes, as a PHP session subsystem error that was raised before any script ran. This error can be a failure to read or write session data, or a rejected session ID, 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 crash nor a session decode failure.
- `High`: The memory failure and an Apache session decode failure occur together.
- `Medium`: The memory failure and an Apache worker crash occur together.

## Triage & Response{% #triage--response %}

- Examine the memory fatal and crash lines on `{{host}}`, and extract the `[client x.x.x.x]` address from the Apache error lines.
- Compare the timestamps of the memory fatal and the crash, since a crash logged in the same second usually belongs to the same failed request, while a crash seconds or minutes later fits a separate exploit request.
- Review Apache access logs on `{{host}}` for large multipart `POST` requests from that client around the signal, especially requests that returned `500` or `502`.
- Determine whether the memory failure came from a legitimate oversized upload by checking the request path and whether the application normally accepts large file 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`) on `{{host}}`, 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.
- Identify the PHP version on `{{host}}` and verify whether it includes the fix (8.5.12, 8.4.27, 8.3.36 or 8.2.35).
- Inspect the host for signs of successful exploitation, such as child processes spawned by Apache or PHP-FPM workers, in-memory executables, new files owned by the web server user, or unexpected outbound connections.
