CVE-2026-59948: Composer: Arbitrary file write outside vendor via malicious transitive package name
Summary A maliciously crafted package, published on an untrusted third party repository other than Packagist.org or Private Packagist, can cause Composer to write files outside the vendor/ directory and outside your project, with attacker-controlled content, during a normal install or update through using an invalid package name, which was not correctly validated by Composer.
Published Jul 20, 2026
Affected packages
composer/composer
- Ecosystem
- Composer (PHP)
- Affected
- >= 2.3.0, < 2.10.2
- Fixed in
- 2.10.2
- Check
composer show composer/composer
composer/composer
- Ecosystem
- Composer (PHP)
- Affected
- >= 1.0.0, < 2.2.29
- Fixed in
- 2.2.29
- Check
composer show composer/composer
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
A maliciously crafted package, published on an untrusted third party repository other than Packagist.org or Private Packagist, can cause Composer to write files outside the vendor/ directory and outside your project, with attacker-controlled content, during a normal install or update through using an invalid package name, which was not correctly validated by Composer.
This is an arbitrary file write that can be used to execute code outside the Composer project's context in which you expected the package code to execute (for example by writing shell startup files, SSH authorized_keys, or a cron entry). It is a supply-chain issue: it requires a malicious or compromised package to be present in the dependency graph, it is not otherwise remotely exploitable against a machine.
The fix makes Composer validate every package produced by dependency resolution before anything is written to composer.lock or installed, and abort with a security error if a package name is not a valid vendor/package name.
Am I affected?
You may be affected if you install packages from an untrusted third party repository, which does not sufficiently validate package names. Packagist.org and Private Packagist are safe, as they validate package names correctly.
Patched versions
Fixed in 2.2.29 and 2.10.2. Composer 1.x is also affected and you should move to a safe 2.x release.
Workarounds
Do not use untrusted package repositories. If you have to, mirror them through an internal repository like Private Packagist.
Credited to iliaal.
References
- https://github.com/composer/composer/security/advisories/GHSA-499r-g7pc-vmp9
- https://nvd.nist.gov/vuln/detail/CVE-2026-59948
- https://github.com/composer/composer/commit/502c6c4f699802d9cf464728b3e8a95674f919a0
- https://github.com/composer/composer/commit/c50b1efd13ebd73f6dca19b31424c5a02bf93cc1
- https://github.com/composer/composer/releases/tag/2.10.2
- https://github.com/composer/composer/releases/tag/2.2.29
- https://github.com/advisories/GHSA-499r-g7pc-vmp9
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Composer (PHP) vulnerabilities
All Composer (PHP) entriesCVE-2026-59944
Composer: GHSA-gjfg-22fp-rrxx fix bypass via symlinked package bin path
medium6.1Oct 2, 2026CVE-2026-84361
Composer arbitrary command execution via a malicious package's Perforce source URL
high7.7Sep 8, 2026CVE-2026-59946
Composer: Path traversal in package bin field lets dependencies chmod arbitrary host files
medium6.1Jul 20, 2026CVE-2026-59947
Composer: URL-embedded HTTP-Basic username leaks to verbose logs (GitHub PAT exposure)
medium4.7Jul 20, 2026CVE-2026-45793
Github Actions issued GITHUB_TOKEN disclosure in GitHub Actions logs
high7.5May 19, 2026CVE-2026-40176
Composer has a command injection via malicious perforce repository
high7.8Apr 14, 2026
