Structural classification
Decisions use parsed statement structure instead of keyword matching.
Safe Boundary classifies the parsed statement, not just its first keyword. Enforce mode refuses non-read-only SQL, dangerous functions, malformed input, and multi-statement bypass attempts.
SELECT account→DELETE users→SELECT pg_read_file()→Why this exists
A regular-expression firewall can miss writes hidden in common table expressions, function calls, comments, or multiple statements. Safe Boundary uses PostgreSQL syntax trees and an explicit dangerous-function deny set.
Observe mode forwards traffic while recording what would have been blocked or masked. Enforce mode changes the data path and fails closed on requests it cannot safely classify.
What it does
Decisions use parsed statement structure instead of keyword matching.
Known file, large-object, and cross-database escape functions are denied inside otherwise read-like SQL.
Blocked SQL returns a policy error before the statement reaches PostgreSQL.
Blocked examples
These are illustrative examples of the kinds of statements the read-only gate is designed to refuse.
| Decision | Statement shape | Enforce-mode result |
|---|---|---|
| CREATE TABLE target… | Blocked as non-read-only | |
| SELECT …; UPDATE … | Blocked as multi-statement / non-read-only | |
| SELECT dangerous_function(…) | Blocked when the function matches the deny policy |
How it works
Build the PostgreSQL syntax tree and reject invalid structure.
Determine whether the statement is read-only and inspect function calls.
Apply observe or enforce behavior from deployment policy.
Record the reason, surface, and available caller attribution.
Protected when
Important boundaries
Continue the story
Block file, large-object, and cross-database escape functions inside read-like SQL.
Protect application, ORM, psql, and BI traffic on the PostgreSQL protocol.
Give AI tools a bounded PostgreSQL query surface with local audit.
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.