phpcsstandards/phpcsutils: PHPCSUtils: Remote code execution via eval() in AbstractArrayDeclarationSniff::getActualArrayKey()
What fixes it
- 1.2.3phpcsstandards/phpcsutils, composerGitHub
composer require "phpcsstandards/phpcsutils:^1.2.3" - 1.2.3phpcsstandards/phpcsutils, PackagistOSV
composer require "phpcsstandards/phpcsutils:^1.2.3"
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Impact
PHPCSUtils versions 1.0.0-alpha1 through 1.2.2 contain an arbitrary code execution vulnerability in PHPCSUtils\AbstractSniffs\AbstractArrayDeclarationSniff::getActualArrayKey(). The vulnerable method is reached by any sniff that extends AbstractArrayDeclarationSniff and calls getActualArrayKey().
Running PHPCS over untrusted PHP code through such a sniff, for example, in a CI pipeline that lints pull requests, or on a developer machine reviewing third-party code, could lead to arbitrary command execution on the scanning host.
The vulnerability happens when the method determines the value of an array key using eval(). A maliciously crafted array key such as 'system'('id') would be executed when the code was scanned.
Known attack vectors
Known code paths that reach the vulnerable method include the following PHPCSExtra sniffs:
Universal.Arrays.DuplicateArrayKeyUniversal.Arrays.MixedArrayKeyTypes
Other packages that call AbstractArrayDeclarationSniff::getActualArrayKey() may also be vulnerable.
Patches
This issue has been fixed in PHPCSUtils 1.2.3. We recommend all users upgrade to 1.2.3 or later.
Workaround
Users who cannot upgrade immediately can disable the sniffs that reach the vulnerable method by adding <exclude> tags to their custom ruleset (replace the placeholder standard and sniff names with the ones used in your setup):
<rule ref="Standard"> <exclude name="Standard.Category.SniffName"/> </rule>
For example, to disable the two PHPCSExtra sniffs listed under "Known attack vectors":
<rule ref="Universal"> <exclude name="Universal.Arrays.DuplicateArrayKey"/> <exclude name="Universal.Arrays.MixedArrayKeyTypes"/> </rule>
To verify that the sniffs have been disabled, run PHPCS with the -e flag, which lists all the sniffs a standard will run. The excluded sniffs should no longer appear in the output:
phpcs -e --standard=/path/to/ruleset.xml
Credits
Many thanks to @rodrigoprimo for responsibly disclosing this vulnerability.
How can I report a security bug?
Please report security vulnerabilities privately via the "Security and quality" tab on the PHPCSUtils repository.
Text from GitHub Advisory Database
Affected versions 28
- phpcsstandards/phpcsutils, composer>= 1.0.0-alpha1, < 1.2.3GitHub
- PHPCSUtilsaffected: >= 1.0.0-alpha1, <= 1.2.2CVE List
- phpcsstandards/phpcsutils, Packagistfrom 1.0.0-alpha1, fixed in 1.2.3OSV
- phpcsstandards/phpcsutils, Packagist1.0.0OSV
- phpcsstandards/phpcsutils, Packagist1.0.0-alpha1OSV
- phpcsstandards/phpcsutils, Packagist1.0.0-alpha2OSV
- phpcsstandards/phpcsutils, Packagist1.0.0-alpha3OSV
- phpcsstandards/phpcsutils, Packagist1.0.0-alpha4OSV
- phpcsstandards/phpcsutils, Packagist1.0.0-rc1OSV
- phpcsstandards/phpcsutils, Packagist1.0.1OSV
- phpcsstandards/phpcsutils, Packagist1.0.10OSV
- phpcsstandards/phpcsutils, Packagist1.0.11OSV
- phpcsstandards/phpcsutils, Packagist1.0.12OSV
- phpcsstandards/phpcsutils, Packagist1.0.2OSV
- phpcsstandards/phpcsutils, Packagist1.0.3OSV
- phpcsstandards/phpcsutils, Packagist1.0.4OSV
- phpcsstandards/phpcsutils, Packagist1.0.5OSV
- phpcsstandards/phpcsutils, Packagist1.0.6OSV
- phpcsstandards/phpcsutils, Packagist1.0.7OSV
- phpcsstandards/phpcsutils, Packagist1.0.8OSV
- phpcsstandards/phpcsutils, Packagist1.0.9OSV
- phpcsstandards/phpcsutils, Packagist1.1.0OSV
- phpcsstandards/phpcsutils, Packagist1.1.1OSV
- phpcsstandards/phpcsutils, Packagist1.1.2OSV
- phpcsstandards/phpcsutils, Packagist1.1.3OSV
- phpcsstandards/phpcsutils, Packagist1.2.0OSV
- phpcsstandards/phpcsutils, Packagist1.2.1OSV
- phpcsstandards/phpcsutils, Packagist1.2.2OSV
References 7
- github.com/PHPCSStandards/PHPCSUtils/commit/9f596b50ea4498ea57b8cb341e920233b044debfFixvia GitHub
- github.com/PHPCSStandards/PHPCSUtils/commit/e8648633ff5b8219b1b3e6346ce85abfc30f1429Fixvia CVE List
- github.com/PHPCSStandards/PHPCSUtils/releases/tag/1.2.3Fixvia CVE List
- github.com/PHPCSStandards/PHPCSUtils/security/advisories/GHSA-r6hr-vr92-vv28Advisoryvia CVE List
- github.com/FriendsOfPHP/security-advisories/blob/master/phpcsstandards/phpcsutils/CVE-2026-65954.yamlAdvisoryvia GitHub
- github.com/advisories/GHSA-r6hr-vr92-vv28Advisoryvia GitHub
- github.com/PHPCSStandards/PHPCSUtils/pull/778Referencevia GitHub