Workik.

PHP2Shell Response Guide: Patch, Mitigate and Harden PHP

Detect PHP2Shell Exploitation Attempts in Your Logs

Search web access logs, PHP error logs, and PHP-FPM logs for PHP2Shell exploitation signals since 17 October 2026 and respond to compromise.

Patching or applying temporary settings stops future attacks, but it does not tell you what happened before you applied the fix. To respond to PHP2Shell (CVE-2026-109618 and CVE-2026-109619) completely, you must check whether anyone tried to exploit your servers while they were exposed. In this lesson, you will examine your web server logs, PHP error logs, and FastCGI Process Manager (FPM) logs to spot signs of an attack and check your file systems for post-exploitation activity.

Previous lesson: PHP2Shell Mitigations When You Cannot Patch Yet | Next lesson: End-of-Life PHP: Backports or Upgrading to PHP 8.4


When to Start Looking and What to Expect

Before you open a terminal, you need a clear timeline. PHP released the security patches and public advisories on 21 October 2026. However, according to Amazon Threat Intelligence, attackers began testing exploitation against honeypots on 17 October 2026. This was four days before the public disclosure.

When you examine your logs for brightline-www (Ubuntu with Apache) and brightline-portal (Docker with nginx and PHP-FPM), you must search from 17 October 2026 onward. Do not start your search on the patch release date.

Common Mistake: Assuming that clean logs mean your server was never targeted or compromised.

Absence of evidence in your logs is not proof of safety. Log files rotate, containers get replaced without persistent logging, and an attacker who gains remote code execution (RCE) can edit or delete log files to hide their tracks. Treat log hunting as one layer of verification, not a guarantee.


Signals of a PHP2Shell Attack

Triggering CVE-2026-109618 (out-of-memory corruption) or CVE-2026-109619 (use-after-free) is noisy. Because public exploits are often unreliable and tied to exact memory layouts, attackers frequently crash PHP worker processes while trying to land a working attack.

According to security researchers at Wiz, you should hunt for four primary signals across your stack:

  • Unusual multipart requests followed by memory limit errors: CVE-2026-109618 is triggered by large or specially structured multipart form data (such as file uploads or form posts) that force PHP to run out of memory during request initialization.
  • Repeated HTTP 500 responses: Failed attempts and fatal errors usually return a 500 Internal Server Error or 502 Bad Gateway to the client.
  • Unusually large or malformed PHPSESSID cookies: CVE-2026-109619 involves the session upload progress feature. Abnormal session cookies on upload requests are worth a closer look.
  • Unexplained PHP worker churn: When memory corruption occurs, the underlying PHP process often crashes with a segmentation fault or abort signal, forcing the master process to spawn a replacement worker.

Hunting for these logs is like checking a building's circuit breakers after a storm. A tripped breaker does not tell you which appliance caused the surge, but it tells you exactly which room had an overload.


Checking PHP Error Logs and PHP-FPM Logs

Your first stop is the PHP error log and the PHP-FPM master log. You are looking for two things: PHP exhausting its allowed memory size, and worker processes dying from operating system signals.

On Linux, signal 11 (SIGSEGV) means a segmentation fault occurred, which happens when a process tries to access memory it should not. Signal 6 (SIGABRT) means the process aborted itself, which often happens when the memory allocator detects corruption. A cluster of these crashes is a strong warning sign.

Run these read-only commands on brightline-www and the host or container for brightline-portal:

bash
Copy

If your logs have already rotated into compressed archives covering 17 October 2026, use zgrep instead of grep:

bash
Copy

For brightline-portal running in Docker, PHP-FPM typically writes to standard error (stderr). Check the container logs since 17 October:

bash
Copy

Pro Tip: A single out-of-memory error on a heavy reporting page may be normal application behavior. A cluster of out-of-memory errors and signal 11 crashes within seconds of each other is a red flag.


Correlating Web Server Access Logs

If you find memory exhaustion errors or worker crashes at a specific timestamp, check your nginx or Apache access logs at that exact second. You want to see what HTTP requests arrived right before the crash.

Use awk to filter your access logs for POST requests that resulted in an HTTP 500 (Internal Server Error) or 502 (Bad Gateway, which nginx returns when an FPM worker crashes mid-request):

bash
Copy

Look closely at the matching lines. Ask three questions:

  1. Did the request target an endpoint that does not normally accept POST data or file uploads, such as a static page or a read-only API route?
  2. Did the same client IP address send dozens of POST requests in a short window?
  3. If your log format records request sizes or cookie headers, is there an unusually large request body or a strange PHPSESSID value?

Quick Challenge: Suppose you see 40 POST requests to /wp-login.php from one IP address in two minutes. The first 39 return HTTP 500, and the 40th returns HTTP 200. What does that pattern suggest? It suggests the attacker crashed the worker 39 times while tuning their attempt, and the 40th request may have succeeded without crashing PHP.


Checking for Signs of Compromise

Finding failed crash attempts in your logs means someone knocked on the door. Now you must check whether anyone got inside. When an attacker achieves RCE on a PHP server, they typically drop a web shell (a small PHP script that accepts commands), modify existing application files, add a scheduled task, or open an outbound network connection.

Run these read-only checks on your servers to look for unexpected changes since 17 October 2026:

bash
Copy

If session upload progress is turned off on your servers, as Lesson 4 recommends, your session files should not contain upload_progress entries. Check the session directory (often /var/lib/php/sessions on Debian and Ubuntu):

bash
Copy

On brightline-www, if find shows a file named /var/www/html/wp-content/uploads/2026/10/cache-helper.php created on 19 October, treat the server as compromised. Upload directories should never contain executable PHP files.


What to Do If You Find a Compromise

If you discover a web shell, an unauthorized cron job, or suspicious outbound connections from a PHP worker, do not simply delete the suspicious file and move on. Once an attacker runs code as your web user, they can read anything that user can read and hide backdoors in places you might miss.

Follow these incident response steps in order:

  1. Isolate the server: Remove the instance or container from your load balancer and block its public network access immediately. Keep administration access open only from your secure management network.
  2. Preserve evidence: Take a disk snapshot of the virtual machine or export the container filesystem, and copy all logs (/var/log, container logs, and command history) to a separate, secure storage location before shutting anything down.
  3. Involve your security team: Notify your internal security operations team or external incident response provider right away.
  4. Rotate all exposed secrets: Assume the attacker read every file accessible to the PHP process. Rotate database passwords, Redis credentials, API keys, payment gateway secrets, WordPress salt keys, and everything stored in .env files or environment variables.
  5. Rebuild from clean source: Do not try to clean an infected server in place. Provision a fresh virtual machine or build a fresh container image with the patched PHP version (such as PHP 8.3.37 or 8.4.28), deploy your application code from a verified Git commit, and restore data from a known clean backup.

Try It Yourself

Practice running a safe log and filesystem audit on one of your staging or production Linux servers:

  1. Run the grep and zgrep commands against your PHP error logs and FPM logs to check for Allowed memory size errors and exited on signal (6|11) entries since 17 October 2026.
  2. Run the awk command on your nginx or Apache access log to list POST requests that returned HTTP 500 or 502.
  3. Run find /var/www -name '*.php' -newermt '2026-10-17' -type f (adjusting /var/www to match your application path) and verify that every modified PHP file corresponds to a legitimate deployment you recognize.

In the next lesson, End-of-Life PHP: Backports or Upgrading to PHP 8.4, you will handle legacy systems like brightline-invoicing on PHP 7.4 and plan a safe upgrade to a supported PHP branch.

Was this lesson helpful?