Postmortems
Four engineering deep dives into SaaS security and reliability.
Practical engineering write-ups covering PostgreSQL privilege boundaries, Stripe event ordering, webhook retry recovery, and subscription access controls. Each article links to the implementation and its supporting tests.
- ENGINEERING NOTE 01 OF 04
Cross-tenant SECURITY DEFINER: the hole RLS can't fix
Bug 01 from our own hardening suite — RLS was enabled the entire time.
caught by: PostgreSQL/tests/hardening/security-definer-boundaries.test.ts · fixed in: 000027_fix_usage_rpc_security.sql
- ENGINEERING NOTE 02 OF 04
Stripe webhook ordering: how an old event downgraded a paying customer
Bug 02 from our own hardening suite — Stripe delivers at-least-once, never in-order.
caught by: PostgreSQL/tests/hardening/stripe-webhook-reliability.test.ts · fixed in: 000026_stripe_event_ordering.sql
- ENGINEERING NOTE 03 OF 04
Webhook retry poisoning: when idempotency becomes the bug
Bug 03 from our own hardening suite — the recovery path itself was broken.
caught by: PostgreSQL/tests/hardening/stripe-webhook-reliability.test.ts · fixed in: 000026_stripe_event_ordering.sql
- ENGINEERING NOTE 04 OF 04
Subscription forgery: when the subscriptions table trusts the client
Bug 04 from our own security review — the subscriptions table was client-writable.
caught by: PostgreSQL/tests/hardening/billing-enforcement.test.ts · fixed in: 000028_security_fixes.sql
The suite that found these ships with the product.
Re-run every attack yourself with npm run test:hardening — the details are in the documentation.