Skip to main content
Mallory
CriticalPublic exploitVulnerability

CVE-2026-17351: pgAdmin 4 AI Assistant read-only transaction bypass via sqlparse/PostgreSQL parser mismatch

Published Jul 31, 2026 · Updated 2 months ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS9.4Critical · v4
EPSS0.48%42nd percentile
CISA KEVNoNot listed
In the wildNonePublic exploit, no exploitation reported
Vendor
Pgadmin
IdentifiersCVE-2026-17351CWE-89 · Improper Neutralization of Special…

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.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

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.

Public exploits

Exploits

2 exploits validated by Mallory's analysis.

View more in app →
pgadmin-ai-assistant-sql-injection-cve-2026-17351-lexer-differential-bypassThis repository is a compact Python PoC for CVE-2026-17351 affecting pgAdmin 4 AI Assistant. It contains two executable scripts and a README. The main exploit logic is in poc.py, which reproduces pgAdmin 9.16-style sqlparse-based read-only validation, then shows that the crafted SQL payload is classified as a single safe SELECT by sqlparse but is executed by PostgreSQL simple query protocol as multiple statements. The payload issues COMMIT to escape BEGIN TRANSACTION READ ONLY and then performs CREATE TABLE pwn(x int), proving write access. The script also demonstrates the mitigation by forcing psycopg3 extended query protocol with prepare_threshold=0 and prepare=True, which causes PostgreSQL to reject the multi-statement text structurally. The second script, prompt_injection_demo.py, models the delivery chain through indirect prompt injection. It stores attacker-controlled text in a column comment on customers.email, reads that comment back, simulates an LLM extracting the embedded SQL and emitting an execute_sql_query-style tool call, then executes the extracted query against PostgreSQL. This demonstrates that the exploit is not just raw SQL injection from direct user input, but a trust-boundary failure where untrusted database content can influence AI-generated tool calls. Repository structure is straightforward: README.md explains the vulnerability, payload, setup, and fix; poc.py is the primary exploit demonstration; prompt_injection_demo.py is a scenario-focused delivery demo. The exploit is real and operational, not merely a detector. It targets pgAdmin 4 versions 9.13 through 9.16 under the documented conditions and requires access to a PostgreSQL instance plus a vulnerable execution path in the AI Assistant.Hunt-Benito · Disclosed Jul 31, 2026 · python · markdown · web · networkOperationalCVE-2026-17566This repository is a small standalone Python proof-of-concept for authenticated remote code execution against pgAdmin 4 via CVE-2026-17566. The repo contains three files: an MIT LICENSE, a README describing the vulnerability and usage, and a single executable Python script, pgadmin4_rce_poc.py, which is the clear entry point. The exploit is not part of a larger framework. It uses Python standard-library networking only: urllib for HTTP(S), cookiejar for session handling, ssl for optional certificate verification bypass, regex for CSRF token extraction, and json for request construction. The script implements a complete attack flow: authenticate to pgAdmin, retrieve a CSRF token from GET /login, submit credentials to POST /login, enumerate accessible server objects via GET /browser/servers, then send a crafted JSON request to POST /import_export/job/<sid>. Its core capability is command execution on the host running pgAdmin. The malicious query is built by build_query(), which returns a payload of the form SELECT 'a\') TO PROGRAM '%s' x'. This is designed to exploit a parsing mismatch between pgAdmin's parenthesis checker and psql string handling, causing the injected TO PROGRAM clause to become active. The operator can supply an arbitrary command with --command or request an automatically generated bash reverse shell with --reverse HOST:PORT. Default demonstration behavior writes command output to /tmp/pgadmin_rce_proof, and the export job uses /tmp/pgadmin_export.csv as the nominal output file. Operationally, this is more than a detector: it performs authentication, target enumeration, payload generation, and exploit delivery. However, it is still a PoC-style standalone script rather than a weaponized framework module. The README also notes the code was based on public analysis and may require minor field adjustments depending on exact pgAdmin version behavior.HackSpeak · Disclosed Aug 4, 2026 · python · markdown · web · networkOperational
Exposure surface

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.

VendorProductType
PgadminPgadmin 4application
FAQ

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.
Activity feed

Recent activity

11 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.

View more in app →
csirt italiaNews · Aug 3, 2026Rilevata molteplici vulnerabilità in pgAdmin - ACNA critical pgAdmin vulnerability caused by a discrepancy between the query validation parser and PostgreSQL's execution parser, allowing an authenticated remote attacker to bypass read-only restrictions, execute unauthorized SQL statements, manipulate database data, and potentially reintroduce arbitrary code execution scenarios.Read more ↗csirt italiaNews · Aug 3, 2026Rilevate molteplici vulnerabilità in pgAdmin - ACNA critical SQL injection vulnerability in pgAdmin 4's AI Assistant execute_sql_query tool caused by an incomplete fix for CVE-2026-12045 and a parser mismatch between sqlparse validation and PostgreSQL execution, allowing an authenticated remote attacker to bypass read-only restrictions, execute unauthorized SQL, modify data, and potentially reintroduce arbitrary code execution scenarios.Read more ↗cvefeed high severityNews · Jul 31, 2026CVE-2026-17351 - pgAdmin 4: AI Assistant read-only transaction bypass via sqlparse/PostgreSQL lexer disagreement (incomplete fix for CVE-2026-12045)A pgAdmin 4 vulnerability in the AI Assistant execute_sql_query tool where sqlparse misclassifies a crafted multi-statement payload as a single statement, allowing PostgreSQL to execute multiple commands, break out of the intended read-only transaction, and re-enable write/RCE bypass. A proposed fix using psycopg prepare=True was ineffective under default configuration; the corrected fix forces extended query protocol by setting conn.prepare_threshold = 0.Read more ↗cveNews · Jul 31, 2026CVE Record: CVE-2026-17351A critical pgAdmin 4 vulnerability in the AI Assistant query execution path where sqlparse and PostgreSQL parse the same input differently, allowing a malicious LLM-supplied query to bypass the intended read-only transaction wrapper and re-enable write/RCE impact via indirect prompt injection.Read more ↗
Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malwareMalware families linked to this CVE, with evidence and IOCs.
Detection signaturesYARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity7Community discussion across Reddit, Mastodon, and other social sources.