/

CVE-2026-87911

Severity:

CRITICAL RISK

(9.6)

OS Command Injection (CWE-78) in postgres-mcp-server

CVE-2026-87911

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-184

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.6)

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

A critical OS command injection vulnerability in the SQL validation component of Amazon awslabs postgres-mcp-server can bypass default read-only enforcement for certain PostgreSQL statements. If attacker-controlled SQL content is processed during an authenticated interaction with the MCP server, operating system commands may execute on the self-managed PostgreSQL host.

Affected context

The issue occurs in deployments using the postgres-mcp-server SQL validation component with its default read-only mode. Risk is present when untrusted or insufficiently constrained SQL content can reach validation and execution paths, particularly where PostgreSQL statements capable of invoking operating system programs are not fully rejected.

Exploit preconditions

  • Attack surface: SQL content processed by the MCP server and forwarded to a self-managed PostgreSQL environment
  • Required access: The attacker may be unauthenticated to the MCP server but must be able to influence content that an authenticated user causes the server to process
  • Trigger point: SQL validation and subsequent database interaction
  • Why exploitation is possible: Read-only enforcement does not reliably reject all statements that can initiate operating system command execution, allowing a dangerous SQL capability to pass through validation

Why this happens

The underlying bug is an incomplete SQL restriction or denylist in a component intended to enforce read-only behavior. This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because database functionality that can invoke operating system programs remains reachable through insufficiently constrained input. The associated CWE-184: Incomplete List of Disallowed Inputs reflects the failure to account for all command-capable statement forms when defining validation rules.

Potential impact

  • Remote execution of operating system commands on the database host
  • Compromise of the self-managed PostgreSQL server
  • Unauthorized access to local files, credentials, or process information
  • Modification or destruction of database data
  • Lateral movement into connected systems or cloud resources
  • Service disruption and broader infrastructure compromise

General mitigation guidance

Mitigation generally focuses on treating read-only enforcement as a positive security policy rather than relying on an incomplete list of prohibited statements.

Common defensive patterns include:

  • Allowing only explicitly approved, parameterized query shapes
  • Separating read-only query execution from administrative or command-capable database features
  • Rejecting statements based on a complete parser-aware policy rather than simple substring or keyword checks
  • Using database roles with minimal privileges and no access to program-execution capabilities
  • Isolating database hosts and restricting their operating system and network permissions
  • Reducing trust in content supplied through authenticated users or downstream integrations
  • Applying defense-in-depth controls at the database, application, host, and network layers

How teams detect issues like this

Detection programs can review SQL validation logic for denylist-based read-only enforcement, incomplete statement coverage, and reliance on regular expressions or keyword matching. Static analysis and code review should identify database APIs or execution paths that permit program invocation, shell interaction, or privileged database operations.

Runtime monitoring can alert on unusual statement classes, database processes spawning operating system children, unexpected child-process execution by the MCP service, and access to sensitive host resources. Policy enforcement in CI can require parser-aware allowlists, least-privilege database roles, and tests covering command-capable and otherwise non-read-only SQL features. Automated security review tools may help identify these patterns but should supplement, not replace, targeted validation tests.

Sources

SourceLink
aws.amazon.comaws.amazon.com/security/security-bulletins/2026-104-aws/
github.comgithub.com/awslabs/mcp/security/advisories/GHSA-fph8-pg5w-78fv
pypi.orgpypi.org/project/awslabs.postgres-mcp-server/1.1.7/

Frequently asked

questions

It can be exploitable through a networked MCP deployment when attacker-influenced content is processed during an authenticated interaction. The attacker does not necessarily need a direct authenticated session, but the deployment's trust and content-handling paths determine practical exposure.

An attacker must be able to place or influence content that reaches the SQL validation and execution flow. An authenticated user's interaction with the MCP server may provide the processing trigger.

Enforce read-only behavior with a parser-aware positive allowlist of permitted query forms, while removing access to command-capable database features and applying least-privilege database roles.

Combine allowlist-based SQL policies, comprehensive tests for all privileged statement classes, strict input trust boundaries, database privilege separation, and monitoring for unexpected database-to-process execution.

Find out what's already
exploitable in your codebase.