CVE-2026-126196: pgEdge Postgres MCP Server read-only bypass via SQL statement smuggling

A high-severity flaw in pgEdge Postgres MCP Server allowed callers to bypass read-only mode and write to databases by smuggling SQL statements through the query_database tool. Fixed in version 1.1.0.

Christopher Ort
By Christopher Ort · 3 min read
Share
A database administrator reviewing security logs on a computer screen in a server room, concerned expression, overhead fluorescent lighting
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
i10X Quick Take

Quick Take

  1. What: CVE-2026-126196 allowed SQL statement smuggling to bypass read-only mode in pgEdge Postgres MCP Server, enabling unauthorized database writes.
  2. Who is affected: Any deployment of pgEdge Postgres MCP Server version 1.0.0 or earlier that relies on read_only mode as a safety boundary and connects with a role holding write privileges.
  3. Fixed version: 1.1.0
  4. What to do: Upgrade to version 1.1.0 or later and review database audit logs for unexpected DDL or DML issued through the MCP connection.
  5. Severity: High (CVSS 8.1)

In plain English

A security flaw in pgEdge Postgres MCP Server let someone send multiple SQL commands in a single request to a database connection that was supposed to be read-only. By adding extra commands after a semicolon, an attacker could change the connection to read-write mode and then create, modify, or delete database tables. The problem is fixed in version 1.1.0, which now only allows one SQL statement per request on read-only connections.

What you should do: If you use this tool to connect to PostgreSQL databases through AI agents or Model Context Protocol clients, you should upgrade immediately and check your database logs to see if anyone exploited this flaw. If you don’t use pgEdge Postgres MCP Server, you can ignore this.

What happened

pgEdge Postgres MCP Server enables SQL queries against PostgreSQL databases through Model Context Protocol compatible clients. Prior to version 1.1.0, the query_database tool on a read_only connection could send unrecognized statements through pgx Exec without bind parameters, selecting PostgreSQL’s simple query protocol and allowing multiple semicolon-separated statements in one request.

A caller could combine transaction or session state changes with database writes. For example, they could append SET TRANSACTION READ WRITE or COMMIT; BEGIN READ WRITE to a request, then write to the database. The flaw was demonstrated by pgEdge engineering against a throwaway PostgreSQL 17.10 instance, creating, altering and dropping real tables.

The vulnerability had several contributing causes:

  • The textual guard matched only the literal strings transaction_read_only and default_transaction_read_only, and never checked READ WRITE or SESSION CHARACTERISTICS.
  • Read detection used strings.HasPrefix against SELECT, WITH, TABLE and VALUES, so anything not recognized as a read (including a read behind a leading comment) was sent down the Exec path.
  • That path called tx.Exec(ctx, sqlQuery) with no bind parameters, so pgx used the PostgreSQL simple query protocol, which accepts several semicolon-separated statements in one message.
  • Session state persisted on pooled connections, so a RESET ALL or DISCARD ALL that cleared default_transaction_read_only on one call left the connection writable by default for later calls.

The flaw affected deployments relying on read_only as a safety boundary and could compromise integrity and availability. Confidentiality was unaffected, since a read-only connection already permits reads.

What you should do

Upgrade to version 1.1.0 or later immediately. After upgrading, review your database audit logs for unexpected DDL or DML issued through the MCP connection. Upgrading prevents further writes but does not tell you whether any occurred.

As a workaround, you can grant the connecting role no write privileges. This is effective, since every route to a write goes through the database’s own permission check, but it removes any legitimate write capability along with the bypass.

What it means

In version 1.1.0, on a read-only connection every query_database statement now uses the extended query protocol, which carries one statement per message, so a multi-statement request is rejected before execution. The guard now inspects the statement with comments removed and literals blanked, and rejects read-write transaction modes, session characteristics, RESET ALL, DISCARD, transaction control and role changes.

Every tool sets the read-only access mode on BEGIN, and the session default is re-applied whenever a connection is returned to the pool, with the connection discarded if that fails.

The advisory notes that connections configured with allow_writes: true keep the previous behaviour, including support for multi-statement scripts, since there is no boundary left to protect in that configuration.

Sources

Christopher Ort

Christopher Ort

Christopher Ort handles SEO, AI agent workflows and PR & partnerships at i10x.ai, the all-in-one AI workspace built by i10X Global Pte. Ltd. in Singapore. He is a graduate of Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU). He is the author of “The Style Penalty”, a study published on SSRN that analyses 1,576 evaluation decisions by four frontier AI models to show how AI-written CVs fare in automated hiring screens; the research has been covered by heise online and t3n.

Editor's picks

  1. CVE-2026-123809: Jinja2 Template Injection in Dynatrace MCP Server
  2. CVE-2026-119613: AshAi tool error messages leak internal module names and data
  3. CVE-2026-123779: Apache Axis2/Java exposes service metadata despite exposeServiceMetadata setting
  4. CVE-2026-18484: IBM ContextForge MCP Gateway denial of service via tool name collision
  5. CVE-2026-123493: Vikunja bot tokens bypass account lockouts, let disabled users keep access