Summary
Postgres MCP Pro contains a restricted-mode authorization bypass in which function-name validation is not consistently applied to RangeFunction nodes used in FROM clauses. An attacker who can submit or influence SQL processed by the service may invoke file-reading functionality and access arbitrary files despite restricted-mode protections.
Affected context
The vulnerability occurs in Postgres MCP Pro deployments that use restricted mode to limit callable database functions while still permitting SQL expressions containing FROM-clause function nodes. Risk depends on whether an attacker can reach the SQL execution interface and cause queries to be processed without equivalent validation across all supported syntax paths.
Exploit preconditions
- Attack surface: The Postgres MCP Pro SQL or database-tool interface
- Required access: Ability to submit, influence, or cause SQL statements to be processed
- Trigger point: Resolution of a RangeFunction node in a FROM clause
- Why exploitation is possible: Restricted-mode function-name checks do not cover this syntax path, allowing disallowed file-reading functions to be reached through an alternate query structure
Why this happens
The underlying bug is incomplete authorization enforcement across equivalent syntax representations. Function restrictions are applied to some invocation paths but omitted for RangeFunction nodes in FROM clauses, allowing a caller to bypass the intended policy by selecting a different parse-tree form. This maps to CWE-863: Incorrect Authorization, because the system fails to consistently enforce access-control rules for a protected operation.
Potential impact
- Sensitive local files may be read
- Database credentials, application secrets, or configuration data could be disclosed
- Host or service reconnaissance may become easier
- Exposed information could support follow-on compromise
General mitigation guidance
Mitigation generally focuses on enforcing authorization consistently at the semantic operation level rather than only at selected syntax nodes.
Common defensive patterns include:
- Apply the same allowlist or denylist to every SQL representation that can invoke restricted functions
- Prefer a narrow, secure-by-default function allowlist over broad name-based filtering
- Parse and normalize statements before policy evaluation so equivalent forms receive equivalent authorization decisions
- Reduce trust in user-controlled SQL and expose only purpose-built operations where possible
- Run the database and MCP service with least-privilege identities and limit access to sensitive filesystem paths
- Treat restricted mode as defense in depth alongside database permissions, filesystem controls, and secret isolation
How teams detect issues like this
Detection approaches can include:
- Static analysis and code review for authorization checks applied to only specific parser node types
- Tests covering equivalent function-invocation forms, including functions represented in FROM clauses
- Policy tests that verify denied functions remain denied after parsing, normalization, and query rewriting
- Monitoring for unusual file-reading function usage or database-tool requests that reference unexpected filesystem resources
- CI enforcement requiring security regression tests for every supported SQL syntax path
- Neutral automated review tools that identify incomplete authorization coverage and inconsistent allowlist enforcement

