Skip to content

[security] GHSA-q896-wrpm-3fwc: SQL injection via the GraphQL listing filter argument (2.4 backport) - #1186

Closed
mcop1 wants to merge 1 commit into
2.4from
fix/graphql-filter-condition-2.4
Closed

mcop1 wants to merge 1 commit into
2.4from
fix/graphql-filter-condition-2.4

Conversation

@mcop1

@mcop1 mcop1 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Backport of #1185 to the 2.4 line (platform version 2025.4, LTS until December 2028).

Vulnerability

Pimcore\Bundle\DataHubBundle\GraphQL\Helper::buildSqlCondition() returned any string it received unchanged. The filter argument of getAssetListing and of the data object listings is JSON-decoded and passed to this builder, so a JSON string at the top level or nested inside $and / $or / a field array ended up in the listing's WHERE clause as raw SQL.

Fix

Same change as #1185: buildSqlCondition() only accepts JSON objects and arrays of objects, at every level, and rejects anything else with a ClientSafeException ("invalid filter: conditions must be JSON objects"); addJoins() skips non-object entries.

Differences to the 1.9 commit:

  • tests/GraphQL/HelperTest.php carries this line's POCL license header.
  • The upgrade note is placed in 2.4.7 (only conflict of the cherry-pick).

Backward compatibility

Helper is @internal. Every filter in the documented syntax produces the same SQL as before; only undocumented raw-string filters are rejected now.

Release notes

The filter argument of getAssetListing and the data object listing queries only accepts the documented JSON syntax: an object, or an array of objects, at every level (including inside $and / $or and field arrays). Any other value, such as a plain JSON string, is rejected with the error invalid filter: conditions must be JSON objects instead of being added to the listing condition. Filters written in the documented syntax are not affected.

Testing

Verified locally against this line's dependencies (pimcore/pimcore container + MariaDB 10.11): full Codeception suite green, including the new HelperTest (11/11) and AssetListingTest cases; PHPStan (project config) and php-cs-fixer clean.

🤖 Generated with Claude Code

… filter argument (2.4 backport)

Helper::buildSqlCondition() returned any string it was given unchanged,
so a JSON string anywhere in the "filter" argument of getAssetListing or
the data object listings ended up in the listing's WHERE clause as raw
SQL. Only JSON objects and arrays of objects are accepted now; anything
else is rejected with a ClientSafeException.

Backport of #1185 from 1.9: the new test file carries this line's POCL
header and the upgrade note sits in this line's patch section.

(cherry picked from commit c60c0b4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcop1 mcop1 added this to the 2.4.7 milestone Oct 29, 2026
@mcop1 mcop1 added the Security label Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:27
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the GraphQL filter-validation backport.

No open issues 🎉

What changed in this PR

Backports the GraphQL listing filter SQL injection fix to the 2.4 line. The change rejects raw SQL strings in filter conditions while preserving documented JSON filter syntax.

Changes:

  • Validates condition types recursively and skips non-object entries during join processing.
  • Adds regression tests for valid filters and rejection of non-object conditions.
  • Documents the filter restrictions in the 2.4.7 upgrade notes.
File Description
tests/​GraphQL/​Resolver/​AssetListingTest.php Tests valid asset filtering and rejection of raw-string filters.
tests/​GraphQL/​HelperTest.php Adds SQL generation, invalid-condition, and join-processing tests.
src/​GraphQL/​Helper.php Rejects invalid condition types and guards join processing.
doc/​01_Installation_and_Upgrade/​01_Upgrade_Notes.md Explains the filter restrictions and client-facing error.

Review effort: Balanced

@mcop1

mcop1 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by forward merge 1.9 → 2.4 → 2026.3 → 2026.x of #1185.

@mcop1 mcop1 closed this Oct 29, 2026
@mcop1
mcop1 deleted the fix/graphql-filter-condition-2.4 branch October 29, 2026 11:33
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants