cbcvebase.
CVE-2026-12045
published 2026-07-31

CVE-2026-12045: The fix for CVE-2026-12045 in pgAdmin 4 9.16 required the LLM-supplied query passed to the AI Assistant's execute_sql_query tool to parse, via sqlparse, as…

PriorityP261high8.8CVSS 3.1
AVNACLPRLUINSUCHIHAH
EPSS
0.66%
49.8th percentile
The fix for CVE-2026-12045 in pgAdmin 4 9.16 required the LLM-supplied query passed to the AI Assistant's execute_sql_query tool to parse, via sqlparse, as exactly one non-transaction-control statement before running it inside a BEGIN TRANSACTION READ ONLY wrapper. sqlparse's string-literal lexing can disagree with PostgreSQL's own parser: under standard_conforming_strings = on (PostgreSQL's default since 9.1), a backslash immediately before a quote is an ordinary character to PostgreSQL, but sqlparse treats it as escaping the quote. A payload such as SELECT '\';COMMIT;CREATE TABLE pwn(x int);SELECT 1 --' therefore parses as a single SELECT to sqlparse's validator, while PostgreSQL executes it as four statements: the smuggled COMMIT ends the wrapping read-only transaction, and the trailing ROLLBACK becomes a no-op. This reintroduces the same write/RCE bypass CVE-2026-12045 was meant to close, reachable via the same indirect prompt-injection delivery (an attacker plants the payload in any object the AI Assistant may read; the LLM emits it as a tool call). An initial candidate fix ran the query with psycopg's execute(..., prepare=True), intending to force PostgreSQL's own Parse step (extended query protocol) to reject multi-statement text regardless of sqlparse's classification. This candidate fix does not work as submitted: psycopg3's PrepareManager silently ignores the prepare argument whenever the connection's prepare_threshold is None, which is pgAdmin's default for every server connection (the per-server "Prepare threshold" field is blank unless an administrator explicitly sets it) -- psycopg3 falls back to the simple query protocol, the same multi-statement-capable path the bypass exploits, so the candidate fix closes nothing on any real-world default configuration. The corrected fix sets conn.prepare_threshold = 0 directly on the dedicated, single-use read-only connection the AI Assistant tool opens, structurally forcing the extended query protocol independen

Affected

3 ranges
VendorProductVersion rangeFixed in
pgadmin.orgpgadmin_4>= 9.13 < 9.179.17
pgadminpgadmin_4>= 9.13 < 9.179.17
pgadminpgadmin_4>= 9.13 < 9.169.16

Detection & IOCsextracted from sources · hover to see the quote

commandCOMMIT↗
commandEND↗
commandROLLBACK↗
commandABORT↗
commandCOPY ... TO PROGRAM↗
  • →Detect multi-statement SQL payloads submitted via the pgAdmin 4 AI Assistant's execute_sql_query tool that begin with transaction-control verbs (COMMIT, END, ROLLBACK, ABORT) — these are the exploit entry point for bypassing the BEGIN TRANSACTION READ ONLY wrapper. ↗
  • →Monitor database audit logs for COPY ... TO PROGRAM statements executed under the pgAdmin user's database role, especially when preceded by a transaction-control verb in the same session — this indicates the RCE escalation path. ↗
  • →Alert on any SQL statement reaching the database driver from the AI Assistant that is not a single statement whose leading token is one of SELECT, WITH, EXPLAIN, SHOW, VALUES, or TABLE — all other leading tokens (including DML, DDL, CALL, COPY, DO, SET/RESET, and transaction-control verbs) are attack indicators. ↗
  • →Inspect database row values, column values, and object comments for prompt-injection payloads designed to cause the LLM to emit multi-statement SQL tool calls — delivery is via attacker-controlled database content readable by the AI Assistant. ↗
  • ·Vulnerable version range is pgAdmin 4 >= 9.13 and < 9.16; upgrade to 9.16 to receive the fix that validates LLM-supplied queries before any database work occurs. ↗
  • ·Risk is critically elevated when the pgAdmin user's database role is a PostgreSQL superuser or holds the pg_execute_server_program privilege, as this enables the RCE escalation path via COPY ... TO PROGRAM. ↗
  • ·PostgreSQL READ ONLY mode alone is insufficient as a control — the exploit explicitly terminates the read-only transaction before executing malicious statements; READ ONLY only backstops residual risks after the fix is applied. ↗
  • ·No Red Hat mitigation is available short of patching; the AI Assistant feature cannot be safely used on affected versions when untrusted users have write access to any database content the assistant may read. ↗

CVSS provenance

nvdv3.18.8HIGHCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
nvdv4.09.4CRITICALCVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
vendor_redhat9.0HIGH
Stop checking back — get the weekly exploitation signal.

Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.