CVE-2026-126197: SQL injection in pgEdge Postgres MCP Server custom pl-do tools

A SQL injection flaw in pgEdge Postgres MCP Server allowed attackers to run arbitrary SQL through custom pl-do tool parameters, bypassing read-only protections. Version 1.1.0 patches the issue.

Christopher Ort
By i10X News Desk · Reviewed by Christopher Ort · 3 min read
Share
A database administrator reviewing audit logs on a terminal screen in a dimly lit server room
Image: AI-generated, i10X
On this page
  1. Quick Take
  2. In plain English
  3. What happened
  4. What you should do
  5. What it means
  6. Sources

A SQL injection vulnerability in pgEdge Postgres MCP Server let attackers execute arbitrary SQL statements by injecting malicious payloads into custom pl-do tool arguments, bypassing read-only database protections and potentially accessing or modifying data available to the connecting role.

i10X Quick Take

Quick Take

  1. What: CVE-2026-126197, a SQL injection flaw in pgEdge Postgres MCP Server custom pl-do tools that allowed arbitrary SQL execution and read-only bypass.
  2. Who is affected: Any deployment of pgEdge Postgres MCP Server version 1.0.0 or earlier that defines at least one custom pl-do tool. sql and pl-func tools are not affected.
  3. Fixed version: 1.1.0, released September 4, 2026.
  4. What to do: Upgrade to version 1.1.0 or later and review database audit logs for unexpected statements issued through the MCP connection, particularly DO blocks.
  5. Severity: High (CVSS 8.8).

In plain English

The pgEdge Postgres MCP Server is a tool that lets AI assistants query PostgreSQL databases through the Model Context Protocol. A security flaw let attackers who could call a custom pl-do tool (a type of database script) sneak their own SQL commands into the tool’s arguments. The server would then run those commands with full database access, even if the connection was supposed to be read-only. The problem is fixed in version 1.1.0.

What you should do: If you use this server and have custom pl-do tools enabled, upgrade immediately and check your database logs for suspicious activity.

What happened

Custom pl-do tools in pgEdge Postgres MCP Server execute PostgreSQL DO blocks with arguments serialised to JSON and interpolated into the block. Prior to version 1.1.0, the block was delimited by fixed dollar-quote tags: $mcp_custom_tool$ for the outer block and $mcp_args$ for plpgsql argument payloads. The server did not check whether argument values contained these tags.

An argument containing $mcp_custom_tool$ closed the DO block early, and everything after it was parsed as SQL. Because the statement used the PostgreSQL simple query protocol (via pgx’s Exec with no bind parameters), the injected text could include multiple semicolon-separated statements and transaction control commands such as SET TRANSACTION READ WRITE or COMMIT; BEGIN READ WRITE. This bypassed the read_only setting and the query_database guard entirely.

An argument containing $mcp_args$ injected procedural code into a plpgsql block body. On a read-only connection this was a complete bypass of read-only mode. On any connection it let the caller read and modify whatever the connecting role could reach, which mattered most where query_database was disabled and custom tools were the only interface offered.

The vulnerability required at least one custom pl-do tool to be defined. sql and pl-func tools pass arguments as bind parameters and were not affected by this injection mechanism.

What you should do

Upgrade to pgEdge Postgres MCP Server version 1.1.0 or later. The fixed version generates dollar-quote tags afresh for every invocation from a random UUID and checks that arguments and code do not contain either tag before the statement is sent.

After upgrading, review your database audit logs for unexpected statements issued through the MCP connection, particularly anything executed alongside a DO block. Upgrading prevents further injection but does not tell you whether any occurred.

If you cannot upgrade immediately, remove or disable custom pl-do tools. Granting the connecting role no write privileges limits what an injected statement can change but does not prevent it reading anything the role can read.

What it means

This vulnerability is part of a broader set of read-only bypass issues in pgEdge Postgres MCP Server 1.0.0 and earlier, covered separately in GHSA-j7mp-839j-jrm7. The custom tools framework had no end-to-end test coverage through the MCP protocol until version 1.1.0, which is how the pl-do tool type came to depend on a single guardrail without the dependency being noticed.

The fix in version 1.1.0 also addresses the read-only bypass through query_database itself by forcing all statements on read-only connections through the PostgreSQL extended query protocol, which accepts exactly one statement per message. The textual statement guard was expanded to recognise transaction access modes, SET SESSION CHARACTERISTICS, RESET ALL, DISCARD, transaction control, SET ROLE, SET SESSION AUTHORIZATION, ALTER ROLE, ALTER USER, ALTER DATABASE, and operations acting outside the transaction that read-only mode does not restrain: DO blocks, COPY ... TO PROGRAM, server-side file functions, and dblink.

The session-level default_transaction_read_only setting is now re-applied when a pooled connection is released, and a connection whose state cannot be confirmed is discarded rather than reused. Previously a RESET ALL or DISCARD ALL persisted on that pooled connection for every later caller.

Sources

Christopher Ort

Christopher Ort

Christopher Ort is the editor of i10X News at i10x.ai. He has worked hands-on with AI tools, models and agent workflows for years and leads i10X’s coverage of AI launches, funding and research. He is the author of “The Style Penalty”, an SSRN study on how frontier AI models judge AI-written CVs, covered by heise online and t3n.

Editor's picks

  1. Georgia Tech’s Academic AI Playbook: 20 Lessons From 67 Real Courses, Free to Reuse
  2. Arcfront’s $1B Run Rate: What the AI Data Startup Confirms and What It Doesn’t
  3. GPT-6.2 Astra Tops Blueprint-Bench 2, 70% Above May Leader GPT-5.5
  4. Deutsche Telekom Puts 100 Million Euros Into Mistral for Sovereign AI in Germany
  5. Inkling 2 Mini: Thinking Machines’ Looped Open Model Tops Qwen on Coding Tests