CVE-2026-17351: pgAdmin 4 AI Assistant read-only transaction bypass via sqlparse/PostgreSQL parser mismatch
- Vendor
- Pgadmin
CVE-2026-17351 is a critical SQL injection and security restriction bypass vulnerability in pgAdmin 4's AI Assistant execute_sql_query tool. The flaw is an incomplete fix for CVE-2026-12045 and affects versions 9.13 through 9.16. The vulnerable logic validates LLM-supplied SQL with sqlparse, requiring it to appear as exactly one non-transaction-control statement before executing it inside a read-only transaction wrapper. Because sqlparse's string-literal lexing can disagree with PostgreSQL's own parser when standard_conforming_strings is enabled, specially crafted input can be classified as a single harmless statement by the validator while PostgreSQL interprets and executes it as multiple statements. This allows an injected transaction-control statement to terminate the intended read-only wrapper, after which attacker-controlled SQL can execute with write semantics. The issue is reachable through indirect prompt injection, where attacker-controlled content read by the AI Assistant causes the model to emit a malicious tool call. An attempted fix using psycopg3 prepared execution was ineffective under pgAdmin's default configuration because prepare_threshold remained unset, allowing fallback to the simple query protocol. The corrected fix forces the dedicated read-only connection to use the extended query protocol so PostgreSQL rejects multi-statement input.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation allows an authenticated remote attacker to bypass the AI Assistant's intended single-statement and read-only enforcement, execute unauthorized SQL statements, and perform database write operations. Because the injected transaction control escapes the protective read-only wrapper, the attacker can modify database contents and reintroduce the same write and potential remote code execution conditions that the earlier fix for CVE-2026-12045 was intended to prevent. The vulnerability also enables security control bypass through indirect prompt injection against the AI-assisted SQL execution workflow.
Mitigation
If you can’t patch tonight, do this now.
If immediate patching is not possible, disable or tightly restrict the AI Assistant execute_sql_query capability. Prevent the assistant from consuming attacker-controlled content that could carry indirect prompt-injection payloads, including untrusted database objects or metadata exposed to the model. Constrain the database privileges available to the assistant connection to the minimum necessary, segregate it from privileged roles, and monitor or block AI-generated SQL execution paths until a fixed release is deployed.
Remediation
Patch, then assume compromise.
Upgrade pgAdmin 4 to version 9.17 or later. The effective remediation is to force the dedicated single-use read-only connection opened by the AI Assistant tool to use PostgreSQL's extended query protocol by setting the connection's prepare_threshold to 0, ensuring PostgreSQL rejects multi-command input during parse/prepare rather than relying on sqlparse classification alone. Any incomplete fix that only passes prepare=True without overriding the default unset prepare threshold is insufficient under default pgAdmin configurations.
Exploits
2 exploits validated by Mallory's analysis.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
References
Frequently asked questions
- Is CVE-2026-17351 exploited in the wild?
- As of Sep 25, 2026, Mallory has no reports of CVE-2026-17351 being exploited in the wild. It is not listed in CISA KEV.
- Is there a public exploit for CVE-2026-17351?
- Yes. Mallory tracks 2 public exploits or proofs of concept for CVE-2026-17351, the earliest disclosed Jul 31, 2026.
- Is there a patch for CVE-2026-17351?
- Upgrade pgAdmin 4 to version 9.17 or later. The effective remediation is to force the dedicated single-use read-only connection opened by the AI Assistant tool to use PostgreSQL's extended query protocol by setting the connection's prepare_threshold to 0, ensuring PostgreSQL rejects multi-command input during parse/prepare rather than relying on sqlparse classification alone.
- What products are affected by CVE-2026-17351?
- Pgadmin 4.
- How severe is CVE-2026-17351?
- CVE-2026-17351 has a CVSS v4 score of 9.4 (Critical) and an EPSS score of 0.48% (42nd percentile) as of Sep 25, 2026.
Recent activity
11 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.