/

CVE-2026-126197

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in pgEdge Postgres MCP Server

CVE-2026-126197

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database reads or modifications through injected SQL

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

pgEdge Postgres MCP Server's custom pl-do tools can be vulnerable to SQL injection when they interpolate JSON arguments into PostgreSQL DO blocks using fixed dollar-quote tags. A client able to invoke an affected tool and supply crafted arguments may inject statements that run with the connecting database role's privileges, including when read_only is enabled.

Affected context

The issue occurs when an MCP server has at least one custom pl-do tool that constructs a PostgreSQL DO block by interpolating JSON arguments into text delimited by fixed dollar-quote tags. Arguments containing those tags can break out of the intended block structure. The described injection mechanism does not affect sql or pl-func tools, which pass arguments as bind parameters.

Exploit preconditions

  • Attack surface: An MCP client can invoke a custom pl-do tool.
  • Required access: The caller must be able to supply arguments to that tool; resulting database actions are limited by the connecting role's privileges.
  • Trigger point: The tool builds and submits a DO block containing caller-controlled arguments.
  • Why exploitation is possible: Fixed dollar-quote delimiters and string interpolation allow arguments to alter the generated SQL. The simple query protocol can accept additional statements and transaction control, so read_only does not reliably prevent the injected actions.

Why this happens

The tool treats caller-controlled JSON values as SQL source by interpolating them into a DO block delimited with fixed tags. An argument can terminate the expected quoting context or alter procedural code, changing the meaning of the generated statement. This is CWE-89: SQL Injection—untrusted input is incorporated into a query without preserving the intended separation between data and SQL syntax.

Potential impact

  • An attacker may read data available to the connecting database role.
  • Injected statements could modify or delete accessible database resources.
  • Transaction-control statements could undermine assumptions made by read_only protections.
  • The database role's privileges could be used to affect other accessible resources.

General mitigation guidance

Defensive designs keep untrusted values separate from SQL syntax. Prefer parameterized interfaces and avoid constructing executable SQL by interpolating caller-controlled values into procedural blocks. Where dynamic SQL is necessary, use database-supported safe quoting and strict allowlists for any identifiers or syntax that cannot be bound as values. Treat read_only as an additional safeguard rather than a substitute for safe query construction, and grant MCP-connected database roles only the privileges their tools require.

How teams detect issues like this

  • Use static analysis to identify SQL strings or DO blocks built with concatenation, formatting, or interpolation of tool arguments.
  • Review custom pl-do tool implementations for fixed quoting delimiters and confirm that caller-controlled values cannot alter SQL structure.
  • Enforce code-review or CI policies that require parameterized query APIs for untrusted values and least-privilege database roles.
  • Audit tool definitions to verify that only intended clients can invoke database-affecting operations.

Sources

SourceLink
github.comgithub.com/pgEdge/pgedge-postgres-mcp/commit/b5b929305de7a22cd6ed7de8ae1be2ac90ca0868
github.comgithub.com/pgEdge/pgedge-postgres-mcp/pull/196
github.comgithub.com/pgEdge/pgedge-postgres-mcp/releases/tag/v1.1.0
github.comgithub.com/pgEdge/pgedge-postgres-mcp/security/advisories/GHSA-r5pp-jx86-r6r9

Frequently asked

questions

The described injection affects custom pl-do tools that interpolate JSON arguments into fixed-tag DO blocks. The sql and pl-func tools use bind parameters and are not affected by this mechanism.

A caller needs the ability to invoke an affected tool and provide its arguments. Any resulting database access is constrained by the privileges of the server's connecting role.

Keep input values separate from SQL syntax by using parameterized interfaces, and avoid interpolating untrusted values into executable procedural blocks.

Review dynamic query construction, enforce parameterization policies, validate any necessary syntax choices against strict allowlists, and limit database roles to the permissions their tools need.

Find out what's already
exploitable in your codebase.