Repository navigation
Releases
v0.5.0
pgveil v0.4.0 — AST Virtual Row-Level Security (RLS), Zero-Config pgveil demo & pgveil init
Highlights
1. AST-Level Virtual Row-Level Security (RLS) & Tenant Predicate Injection
Enforce multi-tenant and regional row isolation directly at the PostgreSQL wire layer with zero database RLS policies, views, or schema changes:
- Parses approved queries using PostgreSQL 17's own C AST (
libpg_query), qualifies table aliases, injectsLEFT JOIN/RIGHT JOINpredicates intoONclauses, wrapsFULL OUTER JOIN&USING/NATURALjoins as filtered subqueries, prevents CTE double-injection on shadowed table names, and emits canonical SQL viapg_query.Deparse. - Works across Simple Query (
'Q'), Extended Query parameterizedParse ('P')frames (,), and nativepgveil mcp. - Supports SQLi-safe quote-escaped session placeholders (
{{db_user}},{{database}},{{application_name}},{{profile}}) and validates everyrow_filterspredicate at config load & hot-reload time. - Security Ordering Invariant: Firewall checks (
block_write_without_where, tautology analysis, CTE taint & PII side-channel guards) strictly execute on the original client SQL before Virtual RLS injects predicates.
2. Zero-Config Interactive Sandbox (pgveil demo)
Try the full Precision Workbench UI (:8088), live PostgreSQL wire proxy (:6432), PII masking, AST firewall, live HITL holds, PII Discovery, and Virtual RLS (tenant_tr) in 3 seconds with zero Docker and zero external PostgreSQL:
brew install duhanguler/tap/pgveil && pgveil demo3. Live Onboarding Wizard (pgveil init)
Scan any existing PostgreSQL database and synthesize a complete, validated pgveil.yaml with a cryptographic HMAC key, discovered column_rules, protected_columns, and denied_tables:
pgveil init --dsn "postgres://user:pass@localhost:5432/mydb" --output pgveil.yaml4. Workbench UI Upgrades (68.7 KB gzip)
- Live debounced AST Pre-Flight bar displays
RLS: +N filtersand a wrappedVirtual RLS →rewritten SQL preview as you type. - Event Inspector slide-over drawer displays both Original SQL and Rewritten SQL (Virtual RLS) with applied predicate badges.
- Ships with the new backwards-compatible
tenant_trdemo profile andRLS Tenant JOINpreset.
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/pgveilpgveil v0.3.1 — Security & Protocol Hardening Release
Security & Protocol Hardening (16 Fixes + Adversarial Regression Tests)
Wire Protocol & Extended Query Hardening
- Block Legacy Fast-Path
FunctionCall ('F'): Closes wire-protocol bypass that could invoke server OID functions (pg_read_file,lo_export) without SQL AST inspection (SQLSTATE 0A000). - Fix Pipelined Extended Query Multi-Statement Bypass: Evaluates every
ParseandBindframe in a pipeline batch so a blocked statement can never hide behind a trailingSELECT 1. - AST Column Alias Provenance:
SELECT full_name AS display_namenow inherits explicitcolumn_rulesmasking on both Wire Proxy and native MCP. - Fix Multi-Frame Flush Relay &
hitl_mode: reject: Accurately relays all response frames onFlush-only batches and marksreject-mode HITL entriesDENIEDimmediately.
PostgreSQL 17 AST Firewall & Side-Channel Oracle Guard
- Expanded Side-Channel Coverage: Blocks projection
LIKE/ILIKE/>/~probes,COUNT(*) FILTER (WHERE tckn ...),ROW_NUMBER() OVER (ORDER BY tckn),DISTINCT ON (tckn),tckn::byteahex exfiltration, andEXPLAIN SELECT ... WHERE tckn = .... - Expanded Dangerous Functions & Catalogs: Walks
VALUES (...),PREPARE,MERGE,CALL,SELECT INTO; blockstable_to_xml,set_config,SET row_security = off,pg_stats(raw planner PII samples), andpg_stat_activity. - Expanded Tautology Detection: Catches
2 > 1,1 <> 2,id = id,NOT (1 = 2), and1 IN (1, 2).
PII Engine, Control Plane API, MCP & Audit Worker
- Standalone AWS Key Fast-Path Fix: Uppercase-heavy AWS keys with <4 digits (
AKIAIOSFODNN7EXAMPLE) are never skipped; added Stripe (sk_live_) and Slack (xoxb-) detectors; UTF-8 rune-safe masking for non-ASCII emails. - Control Plane Secret Redaction & Auth:
GET /api/v1/policiesredacts passwords/keys/webhooks with__PGVEIL_REDACTED__while preserving existing secrets across Policy Studio hot-reloads; added optionalPGVEIL_ADMIN_TOKENBearer auth. - MCP Hardening: Enforces
denied_tables/allowed_tableson schema-qualifieddescribe_table("public.api_secrets"), blocksEXPLAIN ANALYZEinexplain_query, and URL-encodes upstream credentials withUpstreamTLSsupport. - Discovery & Audit Worker Reliability: Deterministic multi-entity strategy selection, 5s per-column timeouts, bounded rate-limiter fingerprint maps, and graceful
SIGTERMfinal-batch flush with a fresh context.
Install / Upgrade
brew update && brew upgrade pgveil
# or fresh install:
brew install duhanguler/tap/pgveilpgveil v0.3.0 — Precision Database Workbench UI & macOS Homebrew Tap
Highlights
1. Precision Database Workbench UI (67 KB gzip embedded binary)
- Complete Anti-Bloat Redesign: Neutral Carbon Dark (
#09090B) + Swiss Light Theme (☀/☾), 1px hairline borders, monochrome primary actions, and full-viewport edge-to-edge split panes. - Line-Numbered SQL & YAML Syntax Highlighter: Zero-dependency tokenizer overlay with
⌘↵live wire execution and debounced AST Pre-Flight inspection bar. ⌘KCommand Palette: Jump views, switch active role profiles, trigger attack/masking presets, or start a live schema PII scan from the keyboard.- Right-Side Audit Inspector Slide-Over Drawer: Inspect full syntax-highlighted SQL, AST fingerprint, policy rule, proxy/upstream latency breakdown, and masked PII entity counts without squishing the audit table.
- PII Discovery Split Pane: Live PostgreSQL schema risk matrix alongside syntax-highlighted, copy-ready
pgveil.yamlpolicy generation.
2. Native macOS Apple Silicon (arm64) & Intel (amd64) Binaries + Homebrew Tap
Install on macOS or Linux in one command:
brew install duhanguler/tap/pgveil
pgveil discover --dsn "postgres://user:pass@localhost:5432/mydb"Container Images
docker pull ghcr.io/duhanguler/pgveil:v0.3.0
docker pull ghcr.io/duhanguler/pgveil-audit-worker:v0.3.0v0.2.0
Changelog
- e0ddcba chore(release): preserve dist/.gitkeep during UI build and use GoReleaser v2 archive formats
- 87afc9a chore(release): split GoReleaser archives per binary and add buildx for GHCR push
- dc851f9 feat(v0.2.0): AST PII side-channel guard, live schema PII discovery, native MCP server, loop breaker, shadow mode & binary pgx Extended Protocol
- 196fea7 feat: initial release of pgveil v0.1.0 — zero-trust PostgreSQL wire-protocol PII masking & AI-agent SQL firewall proxy
- 69150ad fix: emit non-blocking audit event before ReadyForQuery for strict causal ordering