sql_firewall
sql_firewall · Cluster-wide query allowlist firewall with learning, enforcing, permissive, and disabled modes keyed by user and parse-tree fingerprint.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100001 | sql_firewall | sql_firewall | 0.8 | SEC | PostgreSQL | C |
Usage
Sources:
sql_firewall is an abandoned PostgreSQL 9.4 query allowlist prototype. It learns pairs of user ID and parse-tree-derived query ID, then warns about or rejects queries that are not in the learned set. It must be in shared_preload_libraries and requires a restart.
After creating the extension in an administration database, learn a representative workload, inspect sql_firewall.sql_firewall_statements, switch first to permissive, and only then consider enforcing. The hook applies across the cluster even though management views and functions exist only in the database where the SQL extension was created.
Rule export and import use superuser-supplied server file paths and are allowed only while disabled. Query IDs depend on PostgreSQL internal parse trees, so rule files are not portable across major versions. This code supports PostgreSQL 9.4 only and must not be deployed on current PostgreSQL without a full port and security review. It is defense in depth, not a substitute for parameterized SQL, least privilege, or application validation.