PHP2Shell RCE and the LiteLLM PyPI Compromise: Two Incidents, One Lesson

Two things broke in the same week, and both of them touch stacks I build and maintain every day.
The first is the PHP2Shell vulnerability: a pair of critical memory-safety flaws reported in PHP itself that can let an unauthenticated attacker run code on your server. The PHP team shipped emergency patches, Cloudflare pushed WAF rules out, and everyone running WordPress, Drupal, Laravel, or a random legacy PHP script spent a nervous afternoon checking versions.
The second story is quieter but nastier for anyone doing AI automation: a reportedly compromised release of LiteLLM on PyPI that, according to public reporting, drops a credential stealer and a backdoor into your environment. LiteLLM is the kind of package people install to put one clean API in front of OpenAI, Anthropic, Bedrock, and local models. It sits right next to your keys.
I have PHP sites from 2016 still running in production for clients, and I have MCP servers and AI automation pipelines in the same infrastructure. So I want to walk through both incidents from a practitioner's angle: what we actually confirmed, what is still reported and unverified, how to check whether you are exposed, and what to fix today.
Verify before you act. This article was written from public reporting and should be checked against primary sources before you make changes. Confirm the CVE identifiers and patched versions against the PHP security advisories and the PHP downloads page. Confirm the LiteLLM situation against the LiteLLM GitHub security advisories and the PyPI project page. Treat any specific version number in this article as a starting point for your own verification, not as gospel.
Sourcing note and author credentials
I am a full-stack developer who has spent 6+ years building and maintaining production web applications, including legacy PHP sites, modern JavaScript frontends, and AI automation pipelines with MCP servers. I am not a security researcher, and I did not discover or analyze either of these issues. Everything below is drawn from public advisories, vendor release notes, and reporting, with my own operational experience layered on top. Where I could not confirm a detail against a primary source, I say so explicitly.
What we confirmed vs. what's reported
This distinction matters more than usual here, because both stories moved fast and secondary coverage added details that the primary sources did not always support.
What we confirmed (primary sources):
- PHP published security releases and advisories addressing memory-safety flaws in PHP core. The authoritative list is at php.net/security, and the patched release files are on the PHP downloads page.
- Cloudflare publicly announced WAF/virtual-patch coverage for the PHP flaws. That is edge mitigation, not an origin fix.
- LiteLLM maintains a public security advisory feed on its GitHub repository, and release history is visible on PyPI.
What is reported but not independently confirmed by me:
- The specific CVE identifiers for the PHP flaws. I have seen identifiers circulating in coverage, but I am not reproducing them here as fact. Look them up directly on php.net/security and match them to your PHP branch before you act.
- The exact patched version numbers per branch. Check the PHP downloads page and the supported versions page for the current state of your branch.
- The exact affected version range of the LiteLLM compromise, and the specific behavior of the malicious package. The LiteLLM security advisories are the place to confirm whether a release was pulled, yanked, or flagged.
If a detail in this article conflicts with php.net, the LiteLLM advisory feed, or PyPI, trust those sources over me.
What the PHP2Shell vulnerability actually is
The short version, based on public reporting: PHP mishandles request-specific state when a request terminates abnormally, particularly around out-of-memory conditions. Under the right circumstances, memory from one request can leak into another, or the engine can be coerced into executing attacker-controlled data. That is a remote code execution class of bug, which is about as bad as it gets for a web runtime.
The name PHP2Shell is a bit of marketing shorthand for "PHP to shell." It is not a single exploit chain you can copy from a blog post, and I am deliberately not going to describe exploitation mechanics here. What matters for you:
- The flaws are reported to live in PHP core, not in WordPress, not in your theme, not in a plugin. That means patching WordPress alone does not fix it.
- The fix is an emergency PHP release on each supported branch. Confirm the exact patched versions for your branch on the PHP downloads page.
- Cloudflare deployed virtual patches at the edge, which buys time but does not fix your origin server. If traffic reaches your PHP-FPM directly (staging environments, internal tools, IP-address access), the WAF does nothing.
- AI-assisted fuzzing and vulnerability discovery reportedly found this. That is the new normal. Patch cadence is going to keep accelerating.
Who is exposed to the PHP2Shell RCE
If your site runs PHP, you are in scope. That includes the obvious WordPress installs, but also:
| Stack | Exposed? | What to patch |
|---|---|---|
| WordPress on shared hosting | Yes, if host PHP is old | Ask host to update PHP, then update WP core |
| WordPress on VPS (Docker, RunCloud, Forge) | Yes | Rebuild PHP image, redeploy |
| Laravel / Symfony apps | Yes | Update PHP runtime, not just composer deps |
| Drupal | Yes | Patch PHP first, then Drupal core |
| Static Next.js on Vercel | No (no PHP runtime) | Nothing for this CVE |
| Next.js with a PHP legacy backend | Partially | Patch the PHP service separately |
That last row matters more than people think. A lot of "modern" Next.js frontends still proxy to a PHP API or a WordPress headless backend. The React app is fine. The thing behind it is not.
How to check your PHP version in 60 seconds
Start with the boring commands. On a server you control:
php -v
Compare the output against the patched release listed for your branch on the PHP downloads page. If you are on an end-of-life branch, this is a good moment to plan the upgrade rather than just the patch. You can check which branches are still receiving security fixes on the PHP supported versions page.
If you cannot get a shell, drop a temporary file in your web root:
<?php echo PHP_VERSION; ?>
Hit it in the browser, read the version, then delete the file immediately. Do not leave it sitting there.
For Docker-based deployments, check the base image tag:
docker inspect your-php-container | grep -i image
If it says php:8.2-fpm with no patch tag, you are probably running whatever was cached. Pin to a specific patched tag and rebuild.
WordPress-specific checks
WordPress itself does not expose the PHP patch level in the dashboard, which is why so many site owners assume they are fine when they are not. Two things to do:
- Go to Tools > Site Health > Info > Server and read the PHP version.
- Update WordPress core to the current security release even though it does not fix PHP2Shell. Core updates still close the WordPress-specific holes that attackers chain with runtime bugs. See the WordPress security releases for the latest.
If you are on managed WordPress hosting, open a ticket and ask directly: "What PHP version is my site on, and have you applied the PHP2Shell patches?" A good host answers in minutes with a version number. A bad host answers with a marketing paragraph.
Cloudflare protection: useful, not sufficient
Cloudflare's WAF rules for PHP2Shell are genuinely helpful. They block known exploit patterns at the edge, which means your origin does not even see the malicious request. For a lot of small businesses, that is the difference between "we got lucky" and "we got owned" during the window between disclosure and patching.
But I have seen this movie before. Virtual patching creates a false sense of safety. Three failure modes I keep running into:
- Origin is reachable directly. If your server's IP is public and someone finds it, the WAF is bypassed.
- Internal services are unpatched. Staging, admin panels, cron runners, and internal APIs often sit behind no WAF at all.
- Rules get tuned down. Someone disables a rule because a plugin triggers false positives, and the protection quietly disappears.
Treat Cloudflare as a seatbelt, not a brake. Patch the origin.
The LiteLLM PyPI compromise: the AI automation angle
Now the part that scares me more, because it is the direction my work is heading.
According to public reporting, a compromised release of LiteLLM made it onto PyPI. The malicious package reportedly installs a credential stealer and a backdoor. I have not independently verified the affected version range or the exact payload behavior; the LiteLLM security advisories and the PyPI release history are where you confirm that. What is not in dispute is the blast radius if it is true: if you run LiteLLM in a container that holds your OpenAI key, your Anthropic key, your AWS credentials, and a database password, then a supply chain compromise of that one package hands over all of it.
This is not a PHP problem. It is a supply chain attack on Python packages used specifically in AI automation. And it is a preview of what MCP server security is going to look like over the next two years.
Why AI automation stacks are unusually exposed
AI automation code has three properties that make it a juicy target:
- It holds a lot of credentials. Model API keys, vector DB tokens, CRM keys, Slack tokens, and often cloud IAM roles.
- It runs with broad permissions. Agents need to read data, write data, call APIs, and sometimes execute tools.
- It is young. A lot of teams adopted these packages in the last 18 months with
pip installand never pinned versions.
Compare that to a mature PHP app where the dependency tree has been audited for years. The AI stack is where the PHP stack was in 2010.
How to check if you are affected by the LiteLLM compromise
Start with your lockfile, not your requirements.txt:
pip show litellm
Then grep your lockfiles and CI logs for the affected version range, once you have confirmed that range from the LiteLLM security advisories. Check every environment, including notebooks, Lambda layers, and Docker images that were built during the exposure window.
If you find an affected version, treat the host as compromised. Not "maybe." Compromised. That means:
- Rotate every secret the environment had access to. Model keys, cloud keys, database passwords, webhook secrets.
- Check audit logs for outbound calls to unfamiliar domains.
- Rebuild the container from a clean base image rather than trying to surgically remove the package.
- Review any MCP servers or tool integrations that shared that environment.
MCP server security is the next frontier
I build MCP servers. They are wonderful for giving AI agents real capabilities, and they are also a new attack surface that most teams have not thought about.
An MCP server is essentially a bridge between a language model and your systems. If it is misconfigured, you have handed an LLM the keys to your CRM, your file system, or your database. The LiteLLM situation shows how a single bad package can turn a helpful automation layer into an exfiltration channel. The Model Context Protocol specification is the authoritative reference for how auth and transport are meant to work.
Practical rules I apply on every MCP server I ship:
- Authenticate every tool call. Do not trust the agent. Verify the caller with a token or mTLS.
- Scope credentials per server. A calendar MCP server should not have database write access.
- Run in a sandboxed network. No outbound internet unless the tool genuinely needs it.
- Log every tool invocation. You cannot investigate what you did not record.
- Pin dependencies and rebuild on a schedule. Not just when something breaks.
If you are a founder and your developer says "we use MCP servers and AI agents" but cannot answer the five points above, that is a red flag.
A practical response plan for small teams
You do not need a security operations center. You need a checklist that runs in under an hour.
| Step | Action | Who | Time |
|---|---|---|---|
| 1 | Confirm PHP version on all hosts | Dev or host | 10 min |
| 2 | Patch PHP to the current release on your branch | Dev or host | 30 min |
| 3 | Update WordPress core and plugins | Dev | 20 min |
| 4 | Enable Cloudflare WAF rules | Dev | 10 min |
| 5 | Audit litellm and Python deps |
Dev | 20 min |
| 6 | Rotate any exposed AI/cloud keys | Dev + founder | 30 min |
| 7 | Review MCP server permissions | Dev | 30 min |
| 8 | Write down what you found | Anyone | 15 min |
Step 8 is the one everyone skips and the one that pays off next time. A one-page incident log today saves three hours of confusion in six months.
The lesson: one pattern, two incidents
Reframed, PHP2Shell and the LiteLLM compromise are the same story told in two languages. In both cases, a component you did not write, the PHP runtime, a Python package, became the attack surface, and the fix was not in your application code but in your dependency and patch discipline. The teams that got through both incidents calmly were the ones who already knew their versions, pinned their dependencies, and had a rotation plan for secrets. If you take one thing from this article, make it that discipline rather than either specific CVE.
If you want a second opinion on your current setup, or you are planning a build and want security baked in from day one, you can reach out through the contact page.
Frequently asked questions
Am I affected by the PHP2Shell vulnerability if I use WordPress?
WordPress is not the vulnerable component, but it is the most common way people end up running an exposed PHP runtime. The distinction that matters is between your host's PHP version and your WordPress core version: updating WordPress does not change the PHP binary your host runs, so a fully patched WordPress site on an end-of-life PHP branch is still exposed. On shared hosting you usually cannot patch PHP yourself, which is why the first move is a support ticket asking for the exact PHP version and patch status. On a VPS or container platform, you control the base image, so the fix is a rebuild and redeploy rather than a dashboard click.
Does Cloudflare protect me from PHP2Shell without patching?
Cloudflare's WAF rules reduce exposure during the patch window, but the protection is conditional on traffic actually passing through Cloudflare. The common gaps are direct-to-origin access via a public IP, internal services like staging and admin panels that never sit behind the proxy, and rules that get disabled later because of false positives on a plugin. A useful test is to request your origin's IP directly from outside your network and see whether you get a response; if you do, the WAF is not covering that path. Treat edge rules as time you buy, and spend that time patching.
How do I know if I installed the compromised LiteLLM release?
The reliable method is to compare installed versions against the advisory feed rather than against a blog post, because affected ranges can be amended as maintainers investigate. Run pip show litellm in every environment, then check lockfiles, CI build logs, and container image build dates to catch environments where the package was installed as a transitive dependency rather than directly. Notebooks, Lambda layers, and long-lived Docker images are the usual blind spots. If you find an affected version, rebuild from a clean base image instead of uninstalling, because a stealer may have left persistence behind.
What should I ask a developer about AI automation security before hiring?
The most revealing question is not about tools but about process: ask them to walk you through what happens when a dependency they use publishes a security advisory. A strong answer describes pinned versions, automated update PRs, a staging environment to test the bump, and a documented secret-rotation procedure. A weak answer describes reading the news and hoping. Follow up by asking where model API keys live and whether their MCP servers scope credentials per tool, since those two answers tell you whether a single compromised package would expose your whole stack or just one narrow slice of it.