AIDEFEND in Action AIA-0129 Validated Research

pgEdge MCP: SQL Injection, Read-Only Bypass and Missing Write Approval

pgEdge disclosed independent SQL-injection, read-only-enforcement and bundled-client approval defects affecting versions through 1.0.0 and repaired in 1.1.0. A custom pl-do tool could turn argument data into SQL; query_database could defeat an application-level read-only setting; two client defects skipped write confirmation. Database permissions still bound the resulting actions. The source establishes controlled validation, not a malicious customer breach.

Permission BypassTool AuthorizationMCP Security
6 applicable AIDEFEND defenses
Source: pgEdge Postgres MCP Server security advisories 
Author: pgEdge
Original article: Nov 11, 2026

Threat Analysis

  • Separate defects, separate prerequisites: Four pgEdge advisories cover custom pl-do argument injection, query_database read-only bypass, query write-classification errors and custom-tool confirmation omissions. The common affected range is 1.0.0 and earlier, with repairs in 1.1.0. They should not be narrated as one intrusion.
  • Code and authority are different boundaries: Fixed dollar-quote delimiters let data alter SQL in pl-do. Separately, transaction syntax and pooled session state can defeat an application read-only setting when the real database role can write. Removing backend write authority limits both write paths.
  • A missing prompt is a third boundary: The bundled clients can miss writes embedded in apparently read-like queries or custom tools. Those paths require writes to be enabled. The client repair does not turn human confirmation into a universal server-side authorization rule. Supporting primary records: read-only advisory; query-confirmation advisory; custom-tool confirmation advisory.

Applicable AIDEFEND Defenses (6)

AID-H-003.010
Deployed AI Software Vulnerability Remediation Lifecycle
Very High
Deploy pgEdge 1.1.0 or a supported release containing all four fixes, covering server and bundled clients. Verify running artifacts, then separately test delimiter handling, read-only transactions and pool reuse, write-producing queries and custom-tool confirmation. One passing query is not evidence that every path is repaired.
AID-H-017.002
Least-Privilege Tool Architecture
High
Assign the MCP connection a PostgreSQL role with only the required objects and operations. For a genuinely read-only use case, remove write grants and indirect write capabilities instead of relying on read_only or allow_writes labels. Test with the actual connection identity, including inherited roles and executable functions; a separate approved write identity may be needed for legitimate updates.
AID-H-034.003
Server-Side Tool Invocation Validation & Object-Level Authorization
High
For custom tools, keep argument values separate from executable SQL. The operator can replace suitable pl-do tools with the documented parameter-bound sql or pl-func mode; the maintainer must fix delimiter construction where pl-do remains necessary. Validate both wrapper boundaries with harmless delimiter fixtures and preserve the intended statement structure.
AID-H-018.003
High-Impact Independent Validation & Approval Gate
Medium
Where writes require human approval, integrate an independent gate at the execution boundary. Limit the approval path to bounded database operations with known effects. Bind approval to the exact operation, database target, identity and policy, and require the executor to verify the fresh single-use decision and live resource preconditions. Present resolved effects where they can be computed safely; do not execute a write merely to preview it. This is additional engineering, not a native server feature supplied by the client patch.
AID-D-003.003
Agentic Tool Use & Action Policy Monitoring
Medium
After repairing the enforcement logic, record complete authoritative tool-policy outcomes and alert on repeated denied transaction changes or unapproved writes. Correlate the tool identity with PostgreSQL audit events to investigate discrepancies. Decision telemetry must come from the enforced gate; the old classifier’s mistaken allow result cannot by itself reveal the bypass.
AID-H-018.006
Continuous Authorization Verification (Anti-TOCTOU)
Medium
For the additional approval-controlled write path, revalidate the exact signed decision at the final database dispatcher, consume its nonce once, and enforce the approved pre-state in the same transaction as the bounded change. PostgreSQL row or table locks can protect the relevant resource while the adapter compares the approved state and applies the operation. Do not hold locks while waiting for a person. Require independent post-change readback, and deny arbitrary SQL whose effects or atomic preconditions cannot be established.

What Defenders Should Do Now

  • Upgrade both server and clients and exercise each advisory separately in a disposable database. Include later reuse of a pooled connection, not only the first call.
  • Use a truly read-only database role for read-only tasks, accounting for role inheritance and callable functions. Keep custom arguments in parameter-bound APIs; disable vulnerable pl-do tools until repaired.
  • For changes that must always be approved, enforce a bound independent approval at the final execution point. Investigate unexpected DDL/DML using existing database audit records; a patch prevents future exploitation but cannot prove that earlier data was untouched. Supporting primary records: PostgreSQL locking documentation.

Conclusion

AIDEFEND  separates verified patch deployment, database least privilege, safe MCP argument handling, independent approval and trustworthy policy monitoring. That separation makes clear which control repairs a defect, which limits its consequences and which requires additional integration.

Last updated: