Contents
Measured
With real sessions of an agent role, both wire protocols, against PostgreSQL
19beta2 built without assertions (September-October 2026; the commit that
first measured each row is in its last column) – a throwaway cluster from the same
binaries the extension is installed into (tests/cluster.sh), loading it from
cargo pgrx package. Each attack counts only if the error is the gate’s
(a PostgreSQL permission error proves nothing about the gate), and a separate
superuser connection then checks that nothing changed. Every criterion was
declared before the code that it measures.
| criterion | threshold | measured | first measured |
|---|---|---|---|
raw SQL executed from an agent session: SELECT/INSERT/UPDATE/DELETE, DO, CALL, PREPARE, EXPLAIN ANALYZE, writing CTE next to a verb, foreign function next to a verb or as its argument, subquery as argument, reading or forging the record, LOCK, CREATE, SET ROLE, COPY, extended protocol, cursor |
0 | 0 of 20, no side effect | e05e20e, 2026-09-14 |
| raw SQL executed after an error inside the gate (error escaping a verb, error inside execution, cancellation mid-act, rollback in an explicit transaction) | 0 | 0 of 4 | e05e20e, 2026-09-14 |
invented proposals refused at propose: missing table/column/function, wrong literal type, operator without a type, unbound parameter, hidden second statement, broken syntax, transaction control, DDL without permission |
100% | 17 of 17, no side effect | dfdd949, 2026-09-15 |
| control: correct proposals pass and do exactly what they say | 100% | 10 of 10 | dfdd949, 2026-09-15 |
| control: a kept change survives an immediate shutdown (no checkpoint) with its proposal and its execution | 100% | 10 of 10 | dfdd949, 2026-09-15 |
every channel a session can type, tried on purpose (tests/adversarial.sh): two statements in one query, PREPARE/EXECUTE, a cursor, COPY TO/FROM PROGRAM, DO, CALL, EXPLAIN ANALYZE, CREATE TABLE/FUNCTION, SELECT INTO, a writing CTE, a function as a verb argument, a subselect of what it was not granted, SET ROLE, SET SESSION AUTHORIZATION, RESET ALL, DISCARD ALL, VACUUM, CHECKPOINT, LISTEN/NOTIFY, lo_export, a function as the argument of propose_and_commit, and a replication connection |
0 | 0 of 24 had any effect | 48170cc, 2026-10-08 |
what can be slipped past propose (tests/adversarial.sh): two statements, a second one hidden after a comment, DDL without permission, COPY TO PROGRAM, SELECT INTO, FOR UPDATE and a write beyond max_rows, two writing CTEs under a SELECT, an expired verification, another agent’s proposal – and each of the first nine again through propose_and_commit |
0 | 0 of 20 | 48170cc, 2026-10-08 |
control: an agent still runs whoami, discover, proposes, sees before/after in dry_run, commits a read and a write, is refused a second commit, and reads its acts; in one call, reads rows and keeps a write that shows in acts |
100% | 15 of 15 | 48170cc, 2026-10-08 |
garbage into propose and commit (tests/hostile.sh): malformed SQL, unbalanced parentheses, an unterminated comment and dollar quote, a NUL byte, 500 levels of nesting, 100 KB of SQL, 500 parameters, fewer parameters than placeholders, a type that does not exist, invalid UTF-8, a 10 KB identifier, an empty proposal, ids that do not exist, an endless query |
0 crashes | 0 of 16, same postmaster | 4c3eeb4, 2026-09-15 |
the record rewritten (tests/hostile.sh): DELETE, TRUNCATE, disabling the triggers and dropping them, as the agent and as the owner |
0 | 0 of 7 | 4c3eeb4, 2026-09-15 |
the world moved between propose and commit (tests/hostile.sh): table renamed, column dropped, privilege revoked, row gone, a bound assertion broken meanwhile, two sessions at once, and the same proposal committed twice at once |
100% | 9 of 9 | 4c3eeb4, 2026-09-15 |
control: what an owner’s trigger, SECURITY DEFINER function and view do on the agent’s behalf is what this README says |
100% | 5 of 5 | 4c3eeb4, 2026-09-15 |
Those counts are the ones measured then. The cases behind every row are in
tests/adversarial.sh and tests/hostile.sh, which make verify runs: on
2026-11-23 they passed in full in the CI on 18.7 and 19.0, for the code of 0.4.3 and 0.4.4.
Two of those rows found real defects, which is why they exist. TRUNCATE
emptied the whole record: the append-only triggers were FOR EACH ROW, and
TRUNCATE fires no row trigger, so the history could be erased in one statement
with nothing disabled and nothing said. And two concurrent commits of the same
proposal both ran it – each transaction read committed from its own snapshot,
where the other had not committed yet, so a write was applied twice. On a balance
that is a double charge. Both are fixed (0.2.0): statement-level triggers for
TRUNCATE, and the proposal’s row is locked while a commit decides.
What found the 0.2.1 fixes
Not these suites: they were green with both holes open. What found them, on 2026-10-06 against 0.2.0, was an LLM (a Qwen3-8B with a SQL adapter) proposing through the gate against a two-tenant database with row-level security – legitimate tasks, destructive ones written by the model and injected by hand, raw SQL in the agent’s session, and attempts to cross tenants – with a superuser comparing the database before and after every case, and the same cases run by an identical role that was not an agent, to prove the cases were dangerous at all. That run used a private harness and data whose results are not in this repository, so no counts from it are claimed here; what it found is pinned by cases that are in the suites:
- A CTE that writes dodged
max_rows. The limit counted the rows of the outer statement, sowith d as (delete ...) select count(*) from ddeleted 12 rows under a limit of 5. set_config()inside a proposal moved the tenant. The session allowlist judgedSETand the startup parameters, but while the gate runs a proposal its hooks step aside, so... where set_config('app.tenant_id', '2', true) is not nullread the other tenant’s rows.
Since 0.2.1 both are refused at propose (checks 5 and 6 above), and both have
cases in the suites that are red against 0.2.0.