Nine attacks on the live database, written as raw SQL that goes around the application entirely. Each runs in a transaction that is always rolled back — so fire at will. Nothing you do here can stick.
Scoreboard
Nothing fired yet. Pick an attack, or run all nine in a row.
Rows kept: 0 — Every attack ends in ROLLBACK — including one that gets through.
This page connects as obol_app, a role that row-level security applies to.
Debits 1,000 and credits 999. The application would never write this. psql would — so the rule lives in the database.
INSERT INTO transactions (id, org_id, description, currency, occurred_at) VALUES ('txn_01M8NZSRD2KB76K2HB25EK53NK', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Off by one', 'VND', now());
INSERT INTO postings (id, org_id, transaction_id, account_id, amount_minor, currency, base_amount_minor, fx_rate, sequence) VALUES ('post_01M8NZSRD3E1NVPT599RC69SBP', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'txn_01M8NZSRD2KB76K2HB25EK53NK', 'acct_01M317JP1DTENQCBXA9ZXQWJKS', 1000, 'VND', 1000, 1, 0), ('post_01M8NZSRD36SAGAE8RWKEWQ55H', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'txn_01M8NZSRD2KB76K2HB25EK53NK', 'acct_01M317M7FDTB6E7JCGTJWDVG7S', -999, 'VND', -999, 1, 1);
-- What COMMIT would check; we roll back instead. SET CONSTRAINTS ALL IMMEDIATE;
Multiplies the newest posting by ten. Postings are append-only: a mistake is corrected with a reversing entry, never by editing the past.
UPDATE postings SET amount_minor = amount_minor * 10, base_amount_minor = base_amount_minor * 10 WHERE id = 'post_01M31809W4C2ACT0VB2ARGGM80';
Removes the newest posted entry outright. A record that can forget is not a record.
DELETE FROM transactions WHERE id = 'txn_01M317S02WVZP2S7NH7AWMFWS3';
Withdraws one more than the account holds. The balance is kept by a trigger, so the check sees every writer, not only the application.
INSERT INTO transactions (id, org_id, description, currency, occurred_at) VALUES ('txn_01M8NZSRDDXH1QD7Q0S7NQQ5GA', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Overdraw', 'VND', now());
INSERT INTO postings (id, org_id, transaction_id, account_id, amount_minor, currency, base_amount_minor, fx_rate, sequence) VALUES ('post_01M8NZSRDEKN7GK6348A4AJ6AF', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'txn_01M8NZSRDDXH1QD7Q0S7NQQ5GA', 'acct_01M317JR2Y108JT44EMTYK75VW', -13056282766, 'VND', -13056282766, 1, 0), ('post_01M8NZSRDEW6VA2RRCP5Z1KZHR', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'txn_01M8NZSRDDXH1QD7Q0S7NQQ5GA', 'acct_01M317MC70X268YS0XX3HE3AST', 13056282766, 'VND', 13056282766, 1, 1);
A posting that contradicts its account has no row to point at. The mistake is unrepresentable, not merely rejected.
INSERT INTO transactions (id, org_id, description, currency, occurred_at) VALUES ('txn_01M8NZSRDFZY8RY6Q46DXF3YC5', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Wrong currency', 'VND', now());
INSERT INTO postings (id, org_id, transaction_id, account_id, amount_minor, currency, base_amount_minor, fx_rate, sequence) VALUES ('post_01M8NZSRDF6BAR64ERHJKC3Q3F', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'txn_01M8NZSRDFZY8RY6Q46DXF3YC5', 'acct_01M317JP1DTENQCBXA9ZXQWJKS', 100, 'USD', 100, 1, 0);
Two reversals would cancel one entry twice. The first is legitimate; the second meets an index, which — unlike a check in code — cannot lose a race.
INSERT INTO transactions (id, org_id, description, currency, occurred_at, reverses_transaction_id) VALUES ('txn_01M8NZSRDH42Z5W2ND76PSFZBA', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Reversal #1', 'VND', now(), 'txn_01M317Z614JE405KER9CRHA7P2');
INSERT INTO transactions (id, org_id, description, currency, occurred_at, reverses_transaction_id) VALUES ('txn_01M8NZSRDH6M7WPV0JZSVJFBB6', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Reversal #2', 'VND', now(), 'txn_01M317Z614JE405KER9CRHA7P2');
A signed-off month has to reproduce tomorrow. If none is closed yet, the attack closes one first, inside the same doomed transaction.
-- No month is closed yet, so close one first. INSERT INTO accounting_periods (id, org_id, period_month, status, closed_at, closing_transaction_id) VALUES ('per_01M8NZSRDS80X6YVB1S0DEJT92', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', '2026-06-01', 'closed', now(), 'txn_01M317TEX1Q0AQA9DDNYQR41VF');
INSERT INTO transactions (id, org_id, description, currency, occurred_at) VALUES ('txn_01M8NZSRDS4TPXC4EGPNCYNE93', 'org_01M317JM0RHTC4VCY5ZZS4WHM8', 'Back-dated', 'VND', '2026-06-15');
Inserts an account under a tenant this connection is not acting as. The policy refuses the row itself.
INSERT INTO accounts (id, org_id, name, type, currency) VALUES ('acct_01M8NZSRDS4SF3W40BZRB78K1Y', 'org_SOMEONE_ELSE', 'Planted', 'asset', 'VND');
Asks for every account that is not this tenant’s. The right answer is not an error but nothing at all.
SELECT id, org_id, name, balance_minor FROM accounts WHERE org_id <> 'org_01M317JM0RHTC4VCY5ZZS4WHM8' LIMIT 5;
Every attack is one transaction that ends in ROLLBACK whatever happens, so even an attack that succeeds leaves nothing behind. A test removes a guard on purpose and checks exactly that.
The balance rule is checked at COMMIT, which never comes. SET CONSTRAINTS ALL IMMEDIATE asks Postgres to run that check now, exactly as COMMIT would.
The SQL on this page is the SQL that runs. Nothing in it comes from your request: the attacks are a fixed list, aimed at rows read from the ledger a moment earlier.