Dangerous-function denial

A SELECT can still cross a security boundary.

Safe Boundary inspects function calls inside parsed SQL and denies known operations that can read server files, export large objects, or reach outside the intended database path.

Why this exists

Read-only syntax is not the same as harmless behavior

PostgreSQL exposes powerful functionality through callable functions. A statement can begin with SELECT and still attempt file access, large-object export, cross-database access, or another operation that is inappropriate for a bounded application or AI tool.

Safe Boundary walks the parsed function calls and compares them with an explicit dangerous-function policy. A match is blocked before PostgreSQL executes it, even when the surrounding statement otherwise looks read-only.

What it does

Concrete controls, stated precisely.

File-access denial

Recognize configured server-file functions inside expressions, nested queries, and multi-statement input.

Large-object protection

Deny known large-object operations that can move data beyond the intended result path.

Cross-database boundaries

Refuse configured functions that can turn an approved connection into a bridge to another data source.

Function families

Treat read-like SQL with powerful functions as a separate risk class.

DecisionFamilyWhy it is reviewed
Server-file accessCan read from or write to the database host’s filesystem
Large-object operationsCan move data through an alternate result path
Cross-database / external accessCan reach beyond the intended database boundary

How it works

A visible enforcement sequence.

  1. Parse

    Build the complete PostgreSQL syntax tree instead of scanning keywords.

  2. Walk

    Inspect function calls throughout the statement structure.

  3. Match

    Compare resolved names with the configured dangerous-function policy.

  4. Block

    Return a controlled policy error and record the reason before execution.

Protected when

  • SQL routed through Safe Boundary wire or MCP enforcement
  • Known dangerous calls nested inside otherwise read-like statements
  • Bounded query paths that should not reach server files or external databases

Important boundaries

  • The deny policy must evolve with installed extensions and the deployment threat model
  • Least-privileged PostgreSQL roles remain the essential backstop
  • Functions and endpoints outside a routed Safe Boundary surface are not inspected

Continue the story

Related Safe Boundary pages

Test the boundary on a real access path.

Start in observe mode and validate the policy against representative traffic before you enforce it. That gives the team evidence for each decision, along with explicit bypass controls for the cases that need a deliberate exception.