PatchClock

PHP security digest · 29 Sep 2026

PHPCSUtils: Remote code execution via eval() in AbstractArrayDeclarationSniff::getActualArrayKey()

High CVE-2026-65954

Package
phpcsstandards/phpcsutils
Fixed in
1.2.3
Published
Tue 29 Sep 2026, 18:57 LisbonUpdated Sun 25 Oct 2026, 22:25 Lisbon
Installs on Packagist
53M

In plain words

An attacker can run arbitrary commands on the scanning host if PHPCS scans untrusted PHP code using a sniff that extends AbstractArrayDeclarationSniff and calls getActualArrayKey(). This could affect CI pipelines linting pull requests or developers checking third-party code. The flaw is in how PHPCSUtils evaluates array keys and is fixed in version 1.2.3.

Affected versions

PackageAffectedFixed in
phpcsstandards/phpcsutils>= 1.0.0-alpha1, < 1.2.31.2.3

Am I affected?

Check composer.lock for phpcsstandards/phpcsutils at version 1.0.0-alpha1 or later but below 1.2.3. If present, check whether PHPCS scans untrusted PHP and your enabled sniffs include Universal.Arrays.DuplicateArrayKey, Universal.Arrays.MixedArrayKeyTypes, or another sniff extending AbstractArrayDeclarationSniff that calls getActualArrayKey(). Run phpcs -e --standard=/path/to/ruleset.xml with your ruleset path to list enabled sniffs.

What to do

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

composer show phpcsstandards/phpcsutils | grep versions
composer update phpcsstandards/phpcsutils

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

If you cannot upgrade immediately, disable all sniffs that reach the vulnerable method by adding <exclude> tags to the relevant rules in your custom ruleset. This includes Universal.Arrays.DuplicateArrayKey and Universal.Arrays.MixedArrayKeyTypes if enabled. Run phpcs -e --standard=/path/to/ruleset.xml with your ruleset path and confirm the excluded sniffs no longer appear.

The advisory's 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.DuplicateArrayKey
  • Universal.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.

Weakness: CWE-95 Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection'). Reported by rodrigoprimo, FORIMOC, edorian, jrfnl.

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.