Repository navigation
pgveil v0.3.2 — Bulletproof AST Firewall (Taint Tracking, Fail-Closed DDL & 1M+ Fuzzing)
Bulletproof PostgreSQL 17 AST Firewall Architecture
Refactored internal/firewall into modular, fuzz-hardened security engines (firewall.go, ast_walk.go, taint.go, redteam_test.go) verified with 99 adversarial Red-Team CTF test cases and 1,019,085 native Go fuzz executions (FuzzEvaluate) with 0 panics at 56.96 µs/op.
1. Fixed-Point Multi-Hop AST Taint Propagation
- Tracks protected PII column aliases transitively across multi-hop CTEs, explicit CTE/subquery column lists, and nested subqueries — closing bypasses like
WITH leak AS (SELECT id, tckn AS x FROM customers) SELECT id FROM leak WHERE x LIKE '100000%'. - Resolves transitive CTE, scalar subquery, and
UNION/INTERSECT/EXCEPTcolumn provenance soSELECT 0, 'header' UNION ALL SELECT id, full_name FROM customersstill inherits explicitcolumn_rulesmasking on the wire and MCP.
2. Whole-Row Exfiltration, Positional Oracles & PG 16/17 SQL/JSON + XML Guards
- Whole-Row Exfiltration Blocker (
pii_whole_row_exfiltration): BlocksSELECT c::text FROM customers c,SELECT customers::text,SELECT row_to_json(c),SELECT to_jsonb(customers), and bareSELECT c FROM customers c. - Positional Index Oracles: Blocks
SELECT id, tckn FROM customers ORDER BY 2,GROUP BY 1, 2, andUNION ... ORDER BY 2binary-search probes. - PG 16/17 SQL/JSON & SQL/XML: Blocks
JSON_OBJECT,JSON_ARRAY,JSON_OBJECTAGG,JSON_ARRAYAGG,XMLFOREST,XMLELEMENT,XMLSERIALIZE,XMLTABLE,JSON_TABLE,JOIN ... USING (tckn), andLIMIT (SELECT ... WHERE tckn ...).
3. Fail-Closed DDL, COPY Exfiltration, Arithmetic Tautologies & DoS Shields
- Fail-Closed DDL Classification: Explicitly handles 55+ PG17 DDL statements (
ALTER TABLE RENAME,ALTER OWNER,DROP OWNED,CREATE SUBSCRIPTION,CREATE SERVERFDW, etc.) AND defaults any unrecognized top-level statement toisDDL = true. - Automatic
COPY TO STDOUTGuard: Blocks unmaskedCopyDataexfiltration whenevermasking.enabledormax_rows > 0. - Expanded Catalog & Function Lockout: Blocks 75+ dangerous functions (
current_setting,setval,pg_sleep*,pg_advisory_lock*,lo_*,dblink*,*_to_xml*) and 32+ sensitive catalogs (pg_user_mappings,pg_subscription,pg_largeobject,pg_stats*,pg_stat_activity,pg_toast.*). - Arithmetic & Structural Tautology Solver: Catches
1 + 1 = 2,10 - 5 > 3,5 BETWEEN 1 AND 10,1 IS NOT NULL,(1=1) IS TRUE,id IS NOT DISTINCT FROM id,COALESCE(true, false),CASE WHEN 1=1 THEN true,EXISTS (SELECT 1),'x' LIKE '%', recursiveNOT (false OR 1=2), andMERGE ... ON 1=1. - Pre-Parse Hygiene: Rejects embedded NUL bytes (
invalid_nul_byte), enforces1 MiBSQL cap (sql_size_limit), and bounds AST traversal depth (maxASTDepth = 128).
Install / Upgrade
brew update && brew upgrade pgveil
# or fresh install:
brew install duhanguler/tap/pgveil