/

CVE-2026-126196

Severity:

HIGH RISK

(8.1)

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

CVE-2026-126196

Awaiting Analysis

Vulnerability type

Category:

SQL Injection and Read-Only Control Bypass

CWE:

CWE-89, CWE-693

Impact:

Database integrity and availability compromise

Severity:

HIGH RISK

(8.1)

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 could allow a caller to bypass the intended read-only boundary when issuing database queries. If the connection's PostgreSQL role has write privileges, multiple statements or persistent session changes may allow database writes and affect availability.

Affected context

The issue affects the query_database path when it uses a connection marked read-only but sends unrecognized statements through pgx without bind parameters. This can select PostgreSQL's simple query protocol, which permits multiple semicolon-separated statements in one request. Risk depends on the database role's privileges and whether session state is reused through a connection pool; the flaw does not add confidentiality impact beyond reads already allowed by the connection.

Exploit preconditions

  • Attack surface: The MCP server's query_database operation.
  • Required access: The caller must be able to submit requests to that operation.
  • Required database privilege: The PostgreSQL role used by the connection must have write privileges for the affected data or operations.
  • Trigger point: The server executes an unrecognized statement without bind parameters on a connection treated as read-only.
  • Why exploitation is possible: The simple query protocol can process multiple statements in one request, while the read-only safeguard does not reliably prevent transaction or session changes and subsequent writes. Reused pooled connections can retain session state.

Why this happens

The server's read-only control relies on query handling that does not reliably constrain the statements sent to PostgreSQL. Executing unrecognized input without bind parameters can select the simple query protocol, which accepts multiple statements; session state changes may also outlive a request when a connection is pooled. This is associated with CWE-89: Improper Neutralization of Special Elements used in an SQL Command and CWE-693: Protection Mechanism Failure: the query boundary and read-only safeguard do not adequately enforce the intended policy.

Potential impact

  • A caller may perform database writes when the connected role has write privileges.
  • Database records or other writable state could be altered, affecting integrity.
  • Persistent session changes could make later pooled calls writable.
  • Database availability could be affected by unauthorized changes or disruptive operations.
  • Confidentiality impact is not increased beyond the reads already permitted by the connection.

General mitigation guidance

Defensive patterns should make the database enforce read-only behavior rather than relying solely on an application-side flag. Use a least-privilege database role that lacks write permissions for read-only operations, and constrain accepted query forms to the intended use.

Other useful patterns include rejecting multi-statement input where it is not required, avoiding execution paths that select a more permissive query protocol, and resetting or discarding pooled connections when session state may have changed. Treat client-supplied query text as untrusted, and keep database privileges limited to the minimum needed.

How teams detect issues like this

Review query execution paths for calls made without bind parameters, handling of unrecognized statements, and assumptions that a read-only application flag enforces database permissions. Check whether multiple statements are accepted and whether pooled connections are reset after requests.

Static analysis and code review can flag dynamic SQL execution and weak read-only checks. Runtime policy enforcement can also verify that read-only service roles lack write privileges and that query interfaces reject unsupported statement forms.

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-j7mp-839j-jrm7

Frequently asked

questions

A caller who can access the MCP server's query_database operation may be able to exploit it, provided the server's database role has relevant write privileges.

Not in the affected query path. The application-level read-only designation may not prevent multi-statement execution or persistent session changes; database permissions are an important independent safeguard.

Enforce read-only behavior with a database role that lacks write privileges, and constrain query execution to supported, single-statement forms.

Treat client queries as untrusted, limit database privileges, check protocol and statement handling, and ensure pooled connections cannot carry unsafe session state between calls.

Find out what's already
exploitable in your codebase.