Skip to content

Fix TypeError on EXPLAIN FOR CONNECTION without integer ID - #689

Open
des1roer wants to merge 1 commit into
phpmyadmin:6.0.xfrom
des1roer:fix-explain-for-connection-type-error
Open

des1roer wants to merge 1 commit into
phpmyadmin:6.0.xfrom
des1roer:fix-explain-for-connection-type-error

Conversation

@des1roer

Copy link
Copy Markdown

ExplainStatement::parse() assigns the token following FOR CONNECTION straight into public int|null $connectionId. Any token that is not an integer throws an uncaught TypeError from new Parser(...):

Query Before After
EXPLAIN FOR CONNECTION 458 connectionId = 458 connectionId = 458
EXPLAIN FOR CONNECTION TypeError: Cannot assign string ... parser error Unexpected token.
EXPLAIN FOR CONNECTION abc TypeError: Cannot assign string ... parser error Unexpected token.
EXPLAIN FOR CONNECTION 1.5 TypeError: Cannot assign float ... parser error Unexpected token.

This is the issue reported as CVE-2026-121262 (6.0.0, 6.0.1). Both static analysers already flagged it, but the findings had been added to the baselines.

Changes:

  • validate the token the same way KillStatement does (TokenType::Number + is_int), otherwise report Unexpected token.;
  • add parser fixtures for the valid case (parseExplain15) and three invalid ones (parseExplainErr4–6);
  • remove the connectionId / $nextToken->value entries from phpstan-baseline.neon and psalm-baseline.xml, which no longer match.

Verified locally on PHP 8.5: phpunit passes (1030 tests), phpstan and psalm report nothing new. The remaining findings ($argv in tools/*Generator.php, the ContextGenerator psalm baseline entry, the OPTIONS constant type hint) were already there before this change.

🤖 Generated with Claude Code

ExplainStatement::parse() assigned the token after `FOR CONNECTION`
directly to the `int|null $connectionId` property, so any non-integer
token (identifier, float, delimiter, end of query) threw an uncaught
TypeError instead of producing a parser error.

Report "Unexpected token." in that case, as KillStatement does, and
drop the now obsolete phpstan/psalm baseline entries.

Refs CVE-2026-121262

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: des1roer <des1roer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant