PatchClock

PHP security digest · 8 Sep 2026

Composer arbitrary command execution via a malicious package's Perforce source URL

High CVE-2026-84361

Package
composer/composer
Fixed in
2.10.3, 2.2.30
Published
Tue 8 Sep 2026, 22:25 Lisbon
Installs on Packagist
211M

In plain words

A malicious dependency's Perforce source URL can run arbitrary commands when you run composer install or composer update, with the privileges of your user or CI account. This requires the p4 client to be on PATH, attacker-controlled Perforce source metadata from another repository or an untrusted lock file, and the package to be installed from source. Projects using only Packagist.org packages, or machines without p4, are not affected.

Affected versions

PackageAffectedFixed in
composer/composer>= 2.3.0, < 2.10.32.10.3
composer/composer>= 1.0, < 2.2.302.2.30

Am I affected?

Check composer.lock for composer/composer versions >= 2.3.0 and < 2.10.3, or >= 1.0 and < 2.2.30; also check the Composer version actually running with composer --version. For an affected version, all three conditions must hold: p4 is installed and on the Composer machine's PATH; an attacker can control a package's Perforce source metadata through a custom composer-type repository, an inline package repository entry or an untrusted composer.lock; and that package is installed from source because it has no dist artifact or source installs are selected, for example with --prefer-source.

What to do

Check which version you have, then update to a fixed release for your branch (2.10.3, 2.2.30):

composer show composer/composer | grep versions
composer update composer/composer

If your version constraint in composer.json keeps you below a fixed release, raise it first. Whether your configuration is affected, and the exact version ranges, are in the advisory itself.

If you cannot update yet

Upgrading to 2.10.3 or 2.2.30 is the only complete fix. On machines that do not use Perforce, remove p4 from PATH to block this specific attack. Restrict configured repositories to sources you control or trust, and treat lock files from untrusted sources as untrusted input.

The advisory's description

Summary

If the p4 Perforce CLI client is installed, a malicious dependency package from a package repository allowing arbitrary perforce source URLs (packagist.org is safe) could execute arbitrary commands when running composer install or composer update. Composer passed a package's Perforce source address to the p4 CLI client without validating it. The p4 CLI client accepts addresses that mean "run this local command" instead of "connect to this server". This is remote code execution with the privileges of the user or CI account running Composer.

Am I affected?

You are only affected if all of the following are true:

  • The Perforce p4 command line client is installed and on the PATH of the machine running Composer.
  • An attacker can control a package metadata's source section with a perforce type. Packagist.org does not allow perforce source metadata, so you are only exploitable if you rely on another Composer repository (any custom composer-type repository, or an inline package repository entry), or a composer.lock file you obtained from somewhere you do not trust.
  • The package gets installed from source, either because it has no dist artifact or because source installs are selected (for example --prefer-source).

Plainly not affected: anyone without the p4 client installed, which is the large majority of Composer users. Perforce is an optional VCS integration. Also not affected: projects that only consume packages from Packagist.org, which does not allow Perforce source repositories and therefore cannot serve a package with a Perforce source address.

Most realistic way to get hit: a developer workstation or CI image that has Perforce tooling installed, pulling packages from a private or third party Composer repository that an attacker has compromised.

Patched versions

Composer now validates Perforce source addresses before handing them to the p4 client, and accepts only real network endpoints (an optional tcp/ssl transport with a host and port). Addresses that make the client spawn a local process are rejected, and the package fails validation on both update and install, before any p4 command runs. Fixed in Composer 2.10.3 and 2.2.30.

Note: If you legitimately use Perforce with an unusual P4PORT value that is not a plain host and port, Composer will now reject it.

Workarounds

Upgrading is the only complete fix.

Risk reduction short of upgrading:

  • Remove the p4 client from the PATH of machines that run Composer but do not use Perforce. This fully blocks this specific attack, since the vulnerability depends on that client being present.
  • Restrict configured repositories to sources you control or trust, and treat lock files from untrusted sources as untrusted input.

Weakness: CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'). Reported by Saku0512.

The advisory

From OSV.dev, which gathers the GitHub Advisory Database, FriendsOfPHP and Drupal security advisories; the summary is theirs. The description, affected versions, weakness and credits are from the GitHub Advisory Database (CC BY 4.0). "In plain words", "Am I affected?" and "If you cannot update yet" are based on that advisory, and checked to name no version it does not.