Skip to main content
Vulnerability Database/CVE-2026-65954

CVE-2026-65954: PHPCSUtils RCE Vulnerability

CVE-2026-65954 is a remote code execution flaw in PHPCSUtils that allows attackers to execute arbitrary commands through eval() in array-key expressions. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-65954 Overview

CVE-2026-65954 is a code injection vulnerability [CWE-95] in PHPCSUtils, a utility library for PHP_CodeSniffer. The flaw exists in PHPCSUtils\AbstractSniffs\AbstractArrayDeclarationSniff::getActualArrayKey(), which passes attacker-controlled array-key expressions into eval(). When an extending sniff scans untrusted PHP source, callback-form array keys execute arbitrary commands on the scanning host. Known reachable paths include Universal.Arrays.DuplicateArrayKey and Universal.Arrays.MixedArrayKeyTypes. Versions from 1.0.0-alpha1 through 1.2.2 are affected. The issue is fixed in 1.2.3.

Critical Impact

Running an affected sniff against untrusted PHP code grants the attacker arbitrary command execution under the identity of the developer or CI runner performing the scan.

Affected Products

  • PHPCSUtils 1.0.0-alpha1 through 1.2.2
  • PHP_CodeSniffer sniffs that extend AbstractArrayDeclarationSniff and reach getActualArrayKey()
  • PHPCSExtra rulesets using Universal.Arrays.DuplicateArrayKey or Universal.Arrays.MixedArrayKeyTypes

Discovery Timeline

  • 2026-10-12 - CVE-2026-65954 published to NVD
  • 2026-10-13 - Last updated in NVD database

Technical Details for CVE-2026-65954

Vulnerability Analysis

PHPCSUtils is a dependency used by many PHP_CodeSniffer standards, including PHPCSExtra. The AbstractArrayDeclarationSniff base class exposes getActualArrayKey() so child sniffs can normalize array-key expressions during static analysis. To resolve expressions such as string concatenation or numeric arithmetic, the method wrapped the key tokens in a return statement and called eval() on the scanned source. Static analyzers are expected to inspect code, not execute it. Treating untrusted tokens as live PHP violates that boundary and converts a linting pass into arbitrary code execution.

Root Cause

The root cause is unsafe evaluation of attacker-controlled input [CWE-95]. The scanner cannot distinguish between a benign expression like 'foo' . 1 and a callback-form key such as system('id') because both are forwarded to eval(). Any PHP tokens positioned as an array key in the file under analysis run inside the scanner process.

Attack Vector

An attacker commits PHP source containing a weaponized array key to a repository, package, pull request, or any corpus later analyzed with an affected sniff. When a developer or CI job runs phpcs with a ruleset that reaches getActualArrayKey(), the payload executes with the privileges of the scanning user. Exploitation requires user interaction in the form of running the scanner against the hostile code.

php
// Patch excerpt — PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php
// Introduces a token allow-list for callback detection to block eval() of
// attacker-controlled array keys. See release 1.2.3.

private $callbackIndicators = [
    \T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
    \T_END_HEREDOC              => \T_END_HEREDOC,
    \T_END_NOWDOC               => \T_END_NOWDOC,
    \T_CLOSE_PARENTHESIS        => \T_CLOSE_PARENTHESIS,
    \T_CLOSE_CURLY_BRACKET      => \T_CLOSE_CURLY_BRACKET,
    \T_CLOSE_SQUARE_BRACKET     => \T_CLOSE_SQUARE_BRACKET,
];

Source: PHPCSUtils commit e864863

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-65954

Indicators of Compromise

  • Unexpected child processes spawned by php, phpcs, or CI runner shells during static analysis jobs
  • Outbound network connections initiated from a phpcs or vendor/bin/phpcs process
  • PHP source files in untrusted repositories containing array literals whose keys include function calls such as system(...), exec(...), or `...` backticks

Detection Strategies

  • Inventory projects pulling phpcsstandards/phpcsutils and flag any resolved version below 1.2.3 in composer.lock files.
  • Grep CI logs and developer environments for the use of Universal.Arrays.DuplicateArrayKey and Universal.Arrays.MixedArrayKeyTypes sniffs.
  • Audit custom sniffs that extend AbstractArrayDeclarationSniff for reliance on getActualArrayKey().

Monitoring Recommendations

  • Alert on process-tree anomalies where phpcs becomes a parent of shell interpreters, network tools, or package managers.
  • Monitor CI/CD runners for file writes outside the workspace during lint stages.
  • Track composer dependency updates in build pipelines to ensure PHPCSUtils remains at 1.2.3 or later.

How to Mitigate CVE-2026-65954

Immediate Actions Required

  • Upgrade PHPCSUtils to 1.2.3 across all developer workstations, build images, and CI/CD runners.
  • Rebuild and republish any container images that bundle PHP_CodeSniffer with vulnerable PHPCSUtils versions.
  • Stop running affected sniffs against untrusted PHP code until the upgrade is confirmed.

Patch Information

The fix landed in PHPCSUtils 1.2.3 via commit e864863. The patch introduces a callbackIndicators allow-list restricting which token sequences are treated as callbacks, preventing arbitrary expressions from reaching eval(). Review the GHSA-r6hr-vr92-vv28 advisory and the PHPCSUtils 1.2.3 release notes for complete details.

Workarounds

  • Remove Universal.Arrays.DuplicateArrayKey and Universal.Arrays.MixedArrayKeyTypes from active rulesets until patched.
  • Execute phpcs inside an ephemeral, network-restricted sandbox with no credentials or write access to source control.
  • Avoid running static analysis directly against third-party pull requests on privileged runners.
bash
# Upgrade PHPCSUtils to the patched release
composer require --dev phpcsstandards/phpcsutils:^1.2.3
composer update phpcsstandards/phpcsutils --with-dependencies

# Verify the installed version
composer show phpcsstandards/phpcsutils | grep versions

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.