Skip to content

pgveil v0.3.2 — Bulletproof AST Firewall (Taint Tracking, Fail-Closed DDL & 1M+ Fuzzing)

Choose a tag to compare

@github-actions github-actions released this 21 Nov 18:20
· 9 commits to main since this release

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/EXCEPT column provenance so SELECT 0, 'header' UNION ALL SELECT id, full_name FROM customers still inherits explicit column_rules masking 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): Blocks SELECT c::text FROM customers c, SELECT customers::text, SELECT row_to_json(c), SELECT to_jsonb(customers), and bare SELECT c FROM customers c.
  • Positional Index Oracles: Blocks SELECT id, tckn FROM customers ORDER BY 2, GROUP BY 1, 2, and UNION ... ORDER BY 2 binary-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), and LIMIT (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 SERVER FDW, etc.) AND defaults any unrecognized top-level statement to isDDL = true.
  • Automatic COPY TO STDOUT Guard: Blocks unmasked CopyData exfiltration whenever masking.enabled or max_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 '%', recursive NOT (false OR 1=2), and MERGE ... ON 1=1.
  • Pre-Parse Hygiene: Rejects embedded NUL bytes (invalid_nul_byte), enforces 1 MiB SQL 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