Oct 31, 2026 · 8 min read
When PHP Packages Turn Malicious: The Packagist Supply Chain Problem
PHP gets less attention than npm in supply chain discussions, but Composer and Packagist have their own attack patterns. Here's what's been happening and how PHP teams should respond.
PHP doesn't get the same supply chain attention as npm. Partly because the ecosystem is smaller, partly because the attacker community has historically focused on JavaScript. But through 2025, a steady stream of incidents on Packagist and Composer showed that PHP shops have their own problems, and they're different enough that npm-focused defenses don't always translate.
The structural difference
Composer packages are identified by vendor/name, and publishing is tied to a namespace. This cuts down on typosquatting (you can't just publish guzzlehttp/guzzle if someone already owns the guzzlehttp vendor). But it introduces a different risk: namespace transfers and abandoned vendors.
Packagist also doesn't host artifacts directly. It fronts git repositories, usually on GitHub. So the actual source of truth for a Composer package is a git repo, and compromises frequently target the repository rather than Packagist itself. This means GitHub account security is part of your PHP supply chain, whether you think about it or not.
The Composer plugin problem
The most dangerous pattern in 2025 was malicious Composer plugins. Plugins execute code during composer install and composer update with the full privileges of the PHP interpreter. They can read credentials, modify other dependencies' files, or establish persistence, all during what looks like a routine install.
In the Mini Shai-Hulud campaign, a malicious version of intercom/intercom-php changed its package type to composer-plugin and registered a plugin class that subscribed to post-install-cmd and post-update-cmd. When triggered, it ran a shell script that downloaded a JavaScript runtime (Bun) and executed an 11.7 MB obfuscated payload.
A legitimate PHP SDK has no reason to become a Composer plugin, download a JavaScript runtime, and run an obfuscated script. But if you're not checking what plugins your dependencies register, you wouldn't notice until it was too late.
Abandoned maintainer takeovers
The most common attack pattern through 2025 was abandoned-maintainer takeover. A maintainer stops maintaining a package. Their GitHub account expires or gets compromised. An attacker registers the old username, republishes the package with malicious code, and because the Packagist source URL still points to that GitHub repo, every project using the package pulls the new version.
This is the same mechanism that hit ctx on PyPI and phpass on Packagist in earlier years. The defense isn't technical, it's operational: know which of your dependencies are maintained and which are on life support.
Cross-ecosystem attacks
The cleverest attacks in 2025 crossed ecosystem boundaries. In one campaign, attackers altered eight Packagist packages to include malicious installer code, but instead of modifying composer.json, they injected the payload into package.json inside the PHP packages.
This is notable because security teams scanning PHP dependencies tend to look at Composer metadata. If your scanner is configured for PHP and ignores JavaScript lifecycle scripts bundled inside the package, it misses the attack entirely. The payload was a postinstall script that downloaded a Linux binary from a GitHub Releases URL, saved it to /tmp/.sshd, made it executable, and ran it in the background.
The WordPress angle
WordPress plugins are a separate but related problem. In July 2025, the developer of Gravity Forms, a popular WordPress plugin, was compromised. Manual installers from the official website were infected with a backdoor that collected site metadata (URL, admin path, theme, plugins, PHP and WordPress versions) and exfiltrated it to an attacker-controlled domain.
The server responded with base64-encoded PHP malware that was saved as wp-includes/bookmark-canonical.php. The malware enabled remote code execution by unauthenticated users through an eval call with user-supplied input. If you downloaded Gravity Forms between July 10 and 11, 2025, you were affected.
This is a reminder that "download from the official site" is not a sufficient supply chain control when the official site itself is compromised.
What PHP teams should do
Audit your Composer plugins. Run composer show --installed and check which packages declare themselves as composer-plugin. Most projects have no legitimate need for plugins. If you find one you don't recognize, investigate.
Check for abandoned packages. Look at the last commit date and the issue tracker for each dependency. A package that hasn't been updated in two years is a risk, not because it's broken, but because the maintainer's account is a target.
Don't trust package.json inside PHP packages. If your PHP project includes JavaScript build tooling, scan both ecosystems. A malicious postinstall script in a PHP package's package.json will run during npm install even if your Composer audit is clean.
Pin your versions. Use composer.lock and commit it. The same advice applies as with npm: pin to specific versions so a compromised republish doesn't silently land in your build.
Secure your GitHub access. Since Packagist sources point to GitHub, your GitHub account security is part of your PHP supply chain. MFA, scoped tokens, and regular credential rotation matter.
The takeaway
PHP supply chain attacks look different from npm attacks, but the impact is the same: stolen credentials, backdoored code, and a long tail of cleanup. The PHP ecosystem has been quieter about this, which means many teams are less prepared. If you're running a PHP codebase and haven't thought about Composer security since the last time you ran composer update, now is a good time to start.