PHP2Shell patch triage: finding and fixing every PHP in your home lab
PHP shipped emergency fixes for two critical RCE flaws called PHP2Shell. Here is a simple way to find every PHP runtime in a home lab, upgrade it, and check your logs for exploit attempts.
On this page · 9 sections
On 21 October 2026 the PHP security team shipped emergency fixes for two critical remote code execution (RCE) flaws, tracked as CVE-2026-109618 and CVE-2026-109619 and nicknamed PHP2Shell. Both are rated 9.2 (CVSS v4.0), and neither needs a login.
The important detail for home labs: the bugs are in the PHP runtime itself, not in any one application. A site can be fully up to date and still exposed, because the runtime underneath it is not.
What happened, in short
- Both flaws come from the same root problem: PHP can leave its memory in a corrupted state when a request ends abnormally.
- They affect PHP that serves web requests: PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP and LiteSpeed. The PHP team considers mod_php the highest risk.
- The fixed releases are PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35.
- PHP 8.1 and older no longer get updates from the PHP project. Some distributions and LTS vendors backport fixes, and the PHP team published minimal source backports for 7.4, 8.0 and 8.1.
- The PHP team says patching is the only permanent defence. Mitigations reduce exposure but do not fully block attacks.
The caveat: exploitation is harder than the headlines, but not impossible
When this broke, the story was "everything is on fire". The picture has become more nuanced, and it is still changing.
- Early attempts mostly failed. Several security companies saw exploit attempts, including one against Amazon's honeypots four days before the patches, but flagged them as unsuccessful. One report described attackers trying, and failing, to recruit servers into a Mirai botnet variant.
- Public proofs of concept were fragile. A SANS Internet Storm Center analysis found that the PoC it examined needed favourable conditions: a tiny 8 MB memory limit (many real setups use 128 MB), a single-worker server, and server-specific memory offsets read from the target. The author concluded that a universal, reliable exploit is "quite difficult".
- Then it got real. On 26 October, BleepingComputer reported confirmed successful remote code execution against an Apache mod_php server running PHP 8.4.26, caught on a researcher's honeypot. The researcher stressed that this was on an intentionally favourable single-worker setup and is not a measure of how reliable the exploit is elsewhere.
- One attribution was retracted. Unit 42 withdrew its earlier claim that an attack on a European government agency used PHP2Shell.
- Not on CISA's KEV list yet. As of the 26 October reporting, CISA had not flagged the flaws as exploited. My own check of the KEV feed found no PHP2Shell entries. This can change.
My takeaway: don't panic, but don't use "it's hard to exploit" as a reason to wait. Hard is not impossible, and a patch costs less than an investigation.
Step 1: Find every PHP in the lab
Most people patch the PHP they remember. The risk is the one they forgot. Check each of these places.
The host itself
php -v # CLI version
php-fpm -v 2>/dev/null # FPM, if installed
apache2ctl -M 2>/dev/null | grep -i php # mod_php loaded?
dpkg -l | grep -E '^ii\s+php' # Debian/Ubuntu packages
rpm -qa | grep -i '^php' # RHEL/Fedora family
Containers
# Which running containers have PHP, and which version?
for c in $(docker ps --format '{{.Names}}'); do
v=$(docker exec "$c" php -v 2>/dev/null | head -n1)
[ -n "$v" ] && echo "$c: $v"
done
# Which images are PHP-based or tagged as PHP?
docker images | grep -i php
Remember that docker exec only checks running containers. Look at stopped ones and at your compose files too:
grep -rniE 'php|wordpress|nextcloud|drupal|joomla|matomo|phpmyadmin' \
--include='docker-compose*.y*ml' --include='compose*.y*ml' ~/ 2>/dev/null
Things that quietly bundle PHP: WordPress, Nextcloud, Drupal, Joomla, phpMyAdmin, Matomo, wikis, and any "all in one" image. These apps run on whatever PHP is in the container or on the host. Updating the app does not update PHP.
Write the results in a simple table: system, how PHP runs (mod_php, FPM, CLI), version, internet-facing yes/no, fixed?
Step 2: Triage by exposure
Don't patch in random order. Use this:
- Internet-facing and running mod_php: first. This is the setup with the demonstrated exploit.
- Internet-facing, any other PHP: next (PHP-FPM, FrankenPHP, LiteSpeed, php-cgi).
- LAN-only web apps: after that. Still patch them, since one compromised device on the LAN is a stepping stone.
- CLI-only PHP (cron jobs, tools that never serve web requests): lowest priority. The flaws are about web requests.
If something can't be patched today and is exposed, put it behind your VPN or reverse proxy login, or take it offline until it can be. The UK NCSC gave similar advice: update, or take it offline until you can.
Step 3: Upgrade to a fixed release
Containers. Pull a fresh image and recreate. Restarting an old container does nothing.
# Example: official image, pinned to a minor version
docker compose pull
docker compose up -d --force-recreate
docker exec <container> php -v # expect 8.5.12 / 8.4.27 / 8.3.36 / 8.2.35 or newer
If you build your own image, rebuild with --pull (and --no-cache if in doubt) so the base layer really updates.
Distribution packages. Update through your package manager, then restart the PHP service or Apache.
sudo apt update && sudo apt upgrade
sudo systemctl restart apache2 # mod_php
sudo systemctl restart php8.3-fpm # adjust to your version
Distributions often backport a fix without changing the version number, so php -v alone may look "old". Check the changelog instead:
apt changelog php8.3-cli | grep -i -E 'CVE-2026-109618|CVE-2026-109619'
If nothing shows up, don't assume you are safe. Check your distribution's security tracker or wait for the update.
PHP 8.1 or older. The PHP project doesn't update these. Move to a supported branch, or confirm that your vendor has shipped a backport. Treat an unsupported PHP on a public server as the top item on your list.
Restart everything. A package upgrade doesn't help if the old worker processes are still running. Restart FPM, Apache or the container, then confirm the version from inside the running service, not only from the CLI.
If you can't patch yet: stop-gap settings
These are the PHP team's mitigations. They reduce exposure but do not fully protect you.
session.upload_progress.enabled=0, then restart every worker (CVE-2026-109619).memory_limit=-1set so apps can't override it (for examplephp_admin_valuein the FPM pool), a lowpost_max_size(8M if you don't need uploads, 32M if you do), and a container or cgroup limit that kills only the affected worker (CVE-2026-109618).- On PHP 8.5,
fatal_error_backtraces=0.
Check the PHP team's own advisory and blog post summary for exact wording before applying them, because some of these settings have trade-offs for availability.
A second, separate issue. Two days after the patches, PHP disclosed CVE-2026-115560, another RCE risk. It only affects apps with an unusual configuration and application code combination, and there is no patch yet. The advice is the same setting: session.upload_progress.enabled=0. A SANS ISC writer also noted this setting is worth keeping even after patching, as a bypass of the current fix was reportedly possible. I could not confirm that independently, so treat it as unverified, but the setting costs little unless you use upload progress tracking.
Step 4: A simple log-hunting check
You are looking for two things: odd requests and crashing workers. Exploit attempts reportedly send large POST requests that stress memory, and a failed attempt tends to crash or kill a worker.
These are heuristics, not signatures. They will catch noise and can miss real attacks. They are a starting point for a lab, not a replacement for proper detection. CISA also published a SIGMA detection rule for PHP2Shell, which is worth importing if you run a SIEM.
Adjust the log paths for your setup. For containers, replace the file reads with docker logs <container>.
#!/usr/bin/env bash
# php2shell-hunt.sh: quick triage of web and PHP logs. Read-only.
ACCESS=${1:-/var/log/apache2/access.log}
ERROR=${2:-/var/log/apache2/error.log}
echo "== 1. POSTs that returned 5xx or 413 (possible failed attempts) =="
awk '$6 ~ /POST/ && ($9 ~ /^5/ || $9 == 413)' "$ACCESS" | tail -n 50
echo
echo "== 2. Unusually large responses to POSTs (over 500 KB) =="
awk '$6 ~ /POST/ && $10+0 > 500000' "$ACCESS" | tail -n 20
echo
echo "== 3. Top sources of POST requests =="
awk '$6 ~ /POST/ {print $1}' "$ACCESS" | sort | uniq -c | sort -rn | head -n 10
echo
echo "== 4. Crashed or killed workers, memory exhaustion =="
grep -iE 'segmentation fault|exit signal|exited on signal|Allowed memory size|out of memory' \
"$ERROR" | tail -n 50
How to read it:
- Check 1 is the main one. A burst of failed POSTs from one address, around the time of the disclosure (from 17 October onward, since early attempts were reported then), is worth a closer look.
- Check 2 looks for large responses to POSTs. The confirmed in-the-wild case reported a memory dump of roughly 800 KiB in a response. Big POST responses on a site that never normally sends them are unusual.
- Check 4 catches the side effect: workers dying with a segmentation fault. A few might be normal. A cluster that lines up with a sender in check 1 is not.
Note that this uses the standard "combined" log format. Access logs don't record POST bodies, so you can't see the payload, only its shape and what happened next. If you find something suspicious, don't just patch and move on. Check for new files in web directories, unexpected processes running as the web user, and outbound connections you don't recognise.
# Files changed in web roots in the last 7 days
find /var/www -type f -mtime -7 -name '*.php' -ls 2>/dev/null | head -n 50
# Processes owned by the web user
ps -u www-data -o pid,etime,cmd
A short checklist
- List every PHP runtime: host, containers, bundled apps.
- Rank by exposure; mod_php and internet-facing first.
- Upgrade to 8.5.12, 8.4.27, 8.3.36 or 8.2.35 (or newer), or confirm a vendor backport.
- Restart and verify the version inside the running service.
- Set
session.upload_progress.enabled=0unless you need it. - Run the log check and look back to 17 October.
- Write down what you found. Your future self will thank you.
Sources
- PHP Issues Emergency Patches for Two Critical PHP2Shell RCE Flaws as Exploit Attempts Emerge, The Hacker News (the original story; the page text was not fully readable for me, so I relied on its summary and the sources below for details)
- PHP ships emergency patches for critical PHP2Shell flaws, BleepingComputer
- PHP2Shell security flaws now successfully exploited in the wild, BleepingComputer, 26 October
- (Reliable)? php2shell exploitability, SANS Internet Storm Center
- PHP2Shell Exploit Attempts Hit Millions as Attackers Try to Deploy Mirai Malware, The Hacker News (summary only)
- PHP2Shell Exploitation Attempts Continue Amid Suspected N. Korea Global Scanning Activity, The Hacker News (summary only)
- PHP Warns of Another Unpatched RCE Risk Two Days After Emergency PHP2Shell Patches, The Hacker News (summary only)
Enjoyed this? Get the next post by email
One email when something new is up. No spam, and you can unsubscribe anytime.
Comments
No comments yet. Start the conversation.