Executive brief
pgAdmin 4, a popular management tool for PostgreSQL databases, contains a vulnerability in its AI Assistant feature. An attacker can trick the AI into executing malicious database commands by planting specially crafted text in database objects that the AI reads. This could allow an attacker to bypass security restrictions to modify sensitive data or potentially take full control of the database server.
Technical details
A vulnerability exists in the pgAdmin 4 AI Assistant's 'execute_sql_query' tool due to a lexer differential between the 'sqlparse' library and the PostgreSQL server. While pgAdmin attempts to wrap LLM-generated queries in a 'BEGIN TRANSACTION READ ONLY' block and validates them using 'sqlparse', an attacker can use specific backslash-quote sequences to hide a 'COMMIT' statement from the validator. PostgreSQL interprets these sequences differently, allowing the smuggled 'COMMIT' to terminate the read-only transaction and execute subsequent malicious DDL/DML statements. This reintroduces a bypass previously addressed in CVE-2026-12045. The final fix involves forcing the PostgreSQL extended query protocol by setting 'prepare_threshold = 0' on the driver connection, which ensures the server-side parser rejects multi-statement inputs.
Affected products
- pgAdmin pgAdmin 4 9.13 to 9.16
Timeline
- 2026-07-31: advisory: CVE-2026-17351 published
- 2026-07-27: patched: Fix committed to pgAdmin 4 repository
References
- https://github.com/pgadmin-org/pgadmin4/blob/master/web/pgadmin/llm/tools/database.py
- https://github.com/pgadmin-org/pgadmin4/commit/bf4792444446f0e7ab721d23cbd6bfe6afaa7a8b
- https://github.com/pgadmin-org/pgadmin4/commit/ef76102bcd1cdb544eb9b4ef18d3382f22b76752
- https://github.com/pgadmin-org/pgadmin4/issues/10192