13 min read

PHP2Shell Is Here: First Find Out Which PHP You're Actually Running

PHP2Shell (CVE-2026-109618/109619) allows unauthenticated RCE. Five questions to find every PHP on your server, trust the right version number, confirm the patch is live, and contain what you can't fix.
A blue PHP elephant plush toy sitting on a laptop showing code, illustrating a PHP security update check

On October 21, PHP released an emergency security update fixing two critical vulnerabilities dubbed PHP2Shell. The next morning I opened a terminal, and the first thing I did was open a chat window and tell Claude Opus: “There was a really serious PHP vulnerability yesterday. Let's check my servers together.”

So step one of this post's fix is: go talk it over with an AI.

I'm joking, but only partly. What made the conversation valuable wasn't any single command; it was a few questions that kept coming up: “Are you sure there's only one PHP on this server?” “Can you trust that version number?” “After updating, is the new version what's actually running?” This post collects those questions so you can run through the checks yourself, whatever platform you're on.

The short version

If you only have five minutes:

  • Upgrade PHP to a patched release: 8.5.12, 8.4.27, 8.3.36 or 8.2.35. For 8.1 and older, PHP will not publish official patched releases.
  • After updating, always restart PHP-FPM or Apache. The package has been replaced, but the old processes are still running the old code in memory.
  • Confirm that what's “actually running” is the new version, not just what “looks like” the new version.
  • For whatever you can't patch, at least keep it off the open internet.

The rest of this post covers how to do those four things, and the pitfalls I hit on two servers.

What is PHP2Shell?

PHP2Shell is the collective name for CVE-2026-109618 and CVE-2026-109619, both rated CVSS 9.2. An attacker can execute code remotely on the server without logging in, and any PHP serving web pages is in scope, including PHP-FPM, Apache's mod_php, php-cgi, FrankenPHP and LiteSpeed.

Two things are worth remembering:

The problem is in the PHP runtime itself, not in your code, so updating WordPress or plugins won't fix it. On the flip side, if you're only updating within the same release branch (say, 8.4.26 to 8.4.27), you usually don't need to change your site's code. Think of it as a car recall: a part inside the engine gets replaced, the car itself stays as it is. But if your current version no longer gets patches and you have to jump a major version (say, from 7.4 to 8.4), you may run into compatibility issues and need to test separately.

The details leaked the day before the patch was released, which means that by the time the fix came out, people already had the details and were scanning. At times like this, assume “my server may already have been probed,” and go back and check after patching.

Why I can't just give you one command

The official advice is simple: upgrade to a patched release. But “how to upgrade” differs from server to server, because PHP can come from several places:

  • Operating system packages (official Ubuntu, Debian)
  • A control panel's own repository (CloudPanel, cPanel, Plesk, etc.)
  • Docker image
  • Compiled yourself

My two servers happen to be two completely different cases, so rather than handing you commands, I'll give you five questions to answer. The commands are just examples; adapt them to your platform.

Question 1: Which PHPs are actually running on my server?

This is the most important step.

# 系統套件裝了哪些 PHP
dpkg -l | grep -E '^ii\s+(php|libapache2-mod-php)'

# 有哪些 PHP-FPM 或 Apache 服務在跑
systemctl list-units --type=service --no-pager | grep -iE 'php|apache'

# 每一個 PHP-FPM 主程序,連控制面板自己藏的那個也會現形
ps -eo pid,user,cmd | grep 'php-fpm: master' | grep -v grep

# Docker 裡的服務
docker ps --format '{{.Names}}\t{{.Image}}'

I especially recommend the third line. Service names can be all over the place, but the main PHP-FPM process usually shows up as php-fpm: master process, and the parentheses after it tell you which config file it's using. That line is how I discovered the control panel's admin backend was quietly running an old PHP of its own.

If you use Docker, think one step further: docker ps only lists “running” containers. If you have environments that spin up on demand (CTF challenges, preview environments and so on), they won't show up while they're not running. So first list stopped containers and all images:

# 包含已停止的 container
docker ps -a --format '{{.Names}}\t{{.Image}}\t{{.Status}}'

# 主機上所有的 image
docker image ls

For anything whose name suggests it might contain PHP (for example names starting with php, wordpress or apache, or challenge images you built yourself), check them one by one:

docker run --rm --entrypoint sh [image 名稱] -c 'command -v php php-fpm'

Note that this command actually starts a temporary container from the image and deletes it afterwards. Also, if the image has no sh, or PHP isn't on the default PATH, it may print nothing even though PHP is in there. So treat it as a helper, not a 100% reliable verdict.

Finally, if one server has several PHP versions, confirm which one each site actually uses. Each site may have its own FPM pool, or several sites may share the default pool, so you can't judge whether a version is in use just by counting pool config files. Check the web server config to see which PHP-FPM socket requests are really forwarded to:

# nginx 把 PHP 請求轉發到哪裡
sudo nginx -T 2>/dev/null | grep -E 'fastcgi_pass|proxy_pass'

# 每個 PHP 版本的 pool 在哪裡接收請求
grep -rn '^\s*listen\s*=' /etc/php/*/fpm/pool.d/

Match the two up and you'll know which version handles each site. On Apache, look at the socket that SetHandler or proxy:unix: points to in the site config.

Question 2: Can you trust the version number?

The instinct is to check the version with php -v, but there are two traps here.

dpkg -l 'php8.3*' | grep ^ii
zgrep -lE 'CVE-2026-10961[89]' /usr/share/doc/php8.3-*/changelog.Debian.gz

Trap 1: distro version numbers don't track upstream. Ubuntu fixes vulnerabilities by backporting the patch into the existing version, so after Ubuntu 24.04 is patched, php -v still shows 8.3.6. What you need to check is the package version (the patched one for Ubuntu 24.04 is 8.3.6-0ubuntu0.24.04.13), or search the package changelog for the CVE IDs directly:

Conversely, PHP packaged by a control panel usually follows the upstream version number (e.g. 8.4.27-1+...), in which case php -v is accurate. So you need to know who packaged your PHP before you know whether to trust the version number.

Trap 2: php -v shows the command-line version, not the one your site uses. Your site runs on PHP-FPM, so check the FPM binary separately:

php-fpm8.4 -v | head -1

That still only tells you the version of the file on disk, though. Whether the running process has actually switched to it is what Question 4 checks.

If it's the control panel's own PHP, you may not even be able to tell which binary it is. Use the PID from Question 1 to look it up:

sudo readlink /proc/[PID]/exe

Question 3: Where does the patch come from?

On Debian-based systems, apt policy tells you which source a package will be installed from:

apt policy php8.4-fpm

Each version in the output has a priority number next to it, along with the source URL. What I ran into this time: the control panel had set its own repository's priority to 1000, higher than Ubuntu's, so Ubuntu's patched package simply couldn't be installed. I had to wait for the control panel to ship a new version.

You never notice this day to day, but during an emergency patch it's critical: how fast you can patch depends on whoever packages your PHP.

Also, PHP 8.1 and older have reached end of upstream support and won't get new official releases. That said, this time the PHP project specially provided source patches for 7.4, 8.0 and 8.1, and some distros have backported the security fixes; for example, Ubuntu 22.04's php8.1 package fixed these vulnerabilities in 8.1.2-1ubuntu2.28. If you're still on these versions, check whether your distro or panel vendor provides a fix; otherwise you'll need to move to 8.2 or later. And conversely, even if php -v shows an 8.1 version number, you can't conclude either way whether it's been patched; again, check the package version and the maintainer's advisory.

Question 4: Did it really switch to the new version?

An updated package doesn't mean you're fixed. PHP-FPM is a long-running daemon: the package has been replaced, but the old processes in memory are still running the old code. You must restart:

sudo apt update
sudo apt install --only-upgrade 'php8.4*'
sudo systemctl restart php8.4-fpm

Then confirm four things:

# 1. 磁碟上的執行檔是修補版
php-fpm8.4 -v | head -1

# 2. 服務是在更新之後才重新啟動的(看啟動時間)
systemctl status php8.4-fpm --no-pager | grep Active

# 3. 正在跑的主程序用的是哪個執行檔
sudo readlink /proc/$(systemctl show -p MainPID --value php8.4-fpm)/exe

# 4. 網站有回應
curl -sI https://[你的網域] | head -3

If item 3 shows /usr/sbin/php-fpm8.4 (deleted), the process is still using the old binary that the package replaced, meaning it hasn't really restarted onto the new version; restart it again. Only when item 1 says new version, item 2 says freshly restarted and item 3 shows no (deleted) can you say the patched version is running. Item 4 only confirms that HTTP responds; whether the site works properly still needs testing in a browser.

One thing that's easy to miss: if the control panel's admin backend uses its own PHP service, its service name usually isn't php*-fpm, so a wildcard restart won't touch it. Handle it separately.

Finally, don't forget to actually click around your site in a browser, especially features that rely on extensions, like forms, uploads and caching. This time the community reported that one panel's first build of the patched package was missing a few extensions, which broke site features after updating, until it was rebuilt.

Question 5: How do you shrink the exposure of what you can't fix?

There's always something you can't patch right away. For me it was the control panel backend's PHP 8.1. The thinking here is: if you can't fix it, shrink the range from which it can be reached. But remember, this is a temporary risk-reduction measure, not a fix.

Stop versions you're not using. All ten PHP versions on my server were running, but only one was actually used by a site. Disable and mask the unused ones so they don't come back at boot. Before disabling, always use the method from Question 1 to confirm from the nginx or Apache config that no site forwards requests to these versions. Don't rely only on pool config files; get it wrong and you'll take down a live site (replace the version list with the ones you've confirmed are unused):

for v in 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.5; do
  sudo systemctl disable --now php$v-fpm
  sudo systemctl mask php$v-fpm
done

Note: disable, don't remove. Some control panel packages list every PHP version as a required dependency, so removing old versions with apt can rip out the panel along with them. To re-enable later, systemctl unmask undoes it. After stopping them, check right away that your sites still work.

Close ports that don't need to be public. An admin backend usually doesn't need to be open to the whole world. First look at the firewall rules:

sudo ufw status numbered

When deleting a rule, delete it exactly as it was written. I assumed my rule was 8443/tcp, but deleting that didn't match anything. Looking closer, the rule was actually 8433:8443/tcp: one mistyped digit back when I set it up had opened 11 ports in one go.

After deleting, confirm that both the IPv4 and IPv6 rules are gone, then actually try connecting from outside to confirm it really can't be reached:

# 在主機上:IPv4 和 IPv6 的規則都要消失
sudo ufw status | grep 8443

# 在自己的電腦上:應該要逾時或被拒絕
nc -zv -w3 [主機 IP] 8443

The config file shows what you think is true. Connecting from outside shows what actually is.

Reach the backend through an SSH tunnel instead. With the port closed, you can still use the backend; you just open an SSH tunnel first:

ssh -L 8443:127.0.0.1:8443 [管理帳號]@[主機 IP]
# 然後瀏覽器開 https://localhost:8443

How it works: SSH's port 22 stays open, the tunnel enters the server through it, and then connects to the backend locally on the server, and the firewall doesn't block the server connecting to itself by default. The backend is no longer directly exposed to the internet; you have to pass SSH authentication before a tunnel can be set up from outside, which greatly reduces the risk of remote attack. If your SSH still allows password logins, consider switching to key-only while you're at it.

But the PHP vulnerability itself is still there and still running on the server. If another service on the server has something like an SSRF bug, or an attacker has already gained local access some other way, it can still be reached from inside. So this is only a temporary isolation measure and no substitute for the security update.

If your home connection has a dynamic IP, this approach is less likely to lock you out than “only allow my IP through the firewall.” And if SSH breaks too, most VPS providers offer a web console in their control panel that you can use to get back in.

Checking the exposure window

Because the details leaked before the patch, after patching I also went back and looked at what had happened since October 19:

# 網站目錄裡有沒有新增或被改過的 PHP 檔(webshell 最常見的落地方式)
sudo find /var/www /home/*/htdocs -name '*.php' -newermt '2026-10-19' -ls 2>/dev/null

# PHP 有沒有異常崩潰(記憶體破壞類漏洞被嘗試時可能留下的痕跡之一)
sudo journalctl -k --since '2026-10-19' --no-pager | grep -i segfault

# 最近的登入紀錄
last -i | head -10

Don't panic if find lists files; automatic updates or caching in your site's code also create new files, so just confirm each one is legitimate. Crash logs don't necessarily mean you were compromised, but if there are a lot of them, it's worth following up alongside the access logs. Conversely, no crash logs doesn't mean you're fine: a successful exploit won't necessarily crash PHP, nor necessarily write a webshell.

On both of my servers these checks turned up nothing suspicious, and all the logins were mine.

Still, this is only an initial triage. Finding nothing unusual doesn't fully rule out an intrusion. last shows login records, and an attack that comes in through an HTTP vulnerability won't appear there. For a deeper check, you also need to look at nginx or Apache access logs, PHP error logs, unusual processes and outbound connections.

My two servers

Server A: thought it had PHP, it didn't

The first is Ubuntu 24.04, running my blog and a few Docker services. Going through Question 1: no PHP packages installed on the host, so PHP2Shell has nothing to do with this one.

But the inventory was still worthwhile: it reminded me that one service spins up containers on demand, and those environments don't normally appear in docker ps, so the images need checking separately. I also took the chance to install the system's other pending security updates.

Had I started by assuming “I have PHP, upgrade now,” I'd have wasted my time; assuming “I don't have PHP, nothing to do” might have missed the on-demand ones. Take inventory first, then you know what to do.

Server B: thought it had one PHP, it had eleven

The second server is managed with CloudPanel and runs one PHP site. My mental model was “this box has one PHP.” After the inventory, the reality was:

  • Ten PHP-FPM versions (7.1 through 8.5), all running
  • Only 8.4 had a pool configured for a site, and the site worked fine after the other versions were disabled
  • And an eleventh: CloudPanel's own backend PHP, running 8.1.34. PHP won't publish patched releases for it, CloudPanel's repository hadn't been updated yet, and it was directly exposed on 8443

The order I handled things in:

  1. Upgrade 8.4 to 8.4.27, restart, confirm the site works
  2. Disable and mask the other nine unused versions
  3. Discover the backend is stuck on 8.1 with no patch coming any time soon
  4. Close the backend port in the firewall (catching that mistyped rule along the way) and switch to an SSH tunnel
  5. Check the exposure window; nothing unusual found

At this point the backend was no longer directly exposed to the internet and the risk was much lower, but the old PHP's vulnerability itself was still there. So I later found a way to move the backend to 8.4.27 as well, which involves how systemd and FastCGI work.

Lessons from doing this with AI

Back to the opening joke: the whole process took under an hour. My approach was to paste the terminal output to Claude verbatim and let it interpret the results and suggest next steps. It also looked up the latest status in real time, such as patch progress reported in the control panel's GitHub issues, which was much faster than reading through them one by one myself.

But it wasn't always right. At first it used sudo -v to conclude that an account had full sudo rights, and only corrected itself after seeing sudo -l. It also guessed that a database on the server was left over from an old site, before realising the blog itself needs it. So my rule is: understand the output of every step yourself; if you don't, ask “why,” and only move on once you get it. Especially in production, before running a command you should know what it will change and how to roll back if something goes wrong.

The next post comes from me repeatedly asking “why does this work?” along the way.

Checklist

  • [ ] Inventory every PHP on the server: packages, services, FPM master processes, Docker (including stopped containers and images)
  • [ ] Check the nginx or Apache config to confirm which PHP-FPM each site actually forwards to
  • [ ] Find out who packaged your PHP and whether the version number can be trusted
  • [ ] Confirm which source the patch comes from, and whether it's arrived
  • [ ] Restart after updating, confirm from the running master process that it's the patched version (no (deleted)), and that the site works
  • [ ] Only disable and mask unused versions after confirming no site forwards to them
  • [ ] Close ports that don't need to be public (check both IPv4 and IPv6, and test from outside), and reach the admin backend through an SSH tunnel
  • [ ] Check new files, crash logs and login records since October 19

References