Skip to content

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

Merged
MauricioFauth merged 1 commit into
phpmyadmin:6.0.xfrom
des1roer:fix-explain-for-connection-type-error
Nov 18, 2026
Merged

MauricioFauth merged 1 commit into
phpmyadmin:6.0.xfrom
des1roer:fix-explain-for-connection-type-error

Conversation

@des1roer

Copy link
Copy Markdown
Contributor

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>

@MauricioFauth MauricioFauth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@MauricioFauth MauricioFauth self-assigned this Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.06%. Comparing base (4a90c3c) to head (eab502d).

Additional details and impacted files
@@            Coverage Diff            @@
##              6.0.x     #689   +/-   ##
=========================================
  Coverage     96.06%   96.06%           
- Complexity     2290     2293    +3     
=========================================
  Files            89       89           
  Lines          5085     5088    +3     
=========================================
+ Hits           4885     4888    +3     
  Misses          200      200           
Flag Coverage Δ
unit-8.2-ubuntu-latest 96.06% <100.00%> (+<0.01%) ⬆️
unit-8.3-ubuntu-latest 96.06% <100.00%> (+<0.01%) ⬆️
unit-8.4-ubuntu-latest 96.06% <100.00%> (+<0.01%) ⬆️
unit-8.5-ubuntu-latest 96.06% <100.00%> (+<0.01%) ⬆️
unit-8.6-ubuntu-latest 96.06% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@williamdes williamdes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

MauricioFauth added a commit that referenced this pull request Nov 18, 2026
Fix TypeError on EXPLAIN FOR CONNECTION without integer ID

[ci skip]

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
MauricioFauth added a commit that referenced this pull request Nov 18, 2026
Closes #689

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
@MauricioFauth
MauricioFauth merged commit eab502d into phpmyadmin:6.0.x Nov 18, 2026
19 of 20 checks passed
@MauricioFauth MauricioFauth added this to the 6.0.2 milestone Nov 18, 2026
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.

3 participants