Sajjad Mahessar Good Merch Group Free audit
~/sajjad $ cat projects/database-security ← cd ../projects Operations & compliance

Database security audit & remediation

3 migrations · zero downtime

Audited the full production schema — 55 tables — and found around 40 carrying blanket access policies. The anonymous API key had read, write and delete reach over staff PINs, pay rates, salaries, guest records, timesheets, takings, petty cash and the audit log.

Type
Security audit
Category
Operations & compliance
Built with
PostgreSQL · Row-level security · SQL migrations · SECURITY DEFINER
Project
5 of 37
BEFORE · BLANKET POLICY ~40 TABLES OPEN TO THE ANON KEY PINS · PAY · GUESTS · TAKINGS · AUDIT LOG 3 MIGRATIONSZERO DOWNTIME AFTER · SCOPED 55 TABLES · SECURITY DEFINER
55 tables — blanket policy to scoped access

How it shipped

A four-stage remediation, sequenced explicitly so it could go out mid-service without locking staff out: additive scoped policies first, then an app release routing queries through authenticated clients, then confirmation of device rollout, then removal of the permissive policies.

Three migrations delivered — payroll, operations and rota, and financial, stock and document tables — all built on SECURITY DEFINER helper functions.

Documented honestly

  • An unrate-limited PIN endpoint.
  • Twelve-hour JWTs with no refresh.
  • Row-level security filters rows, not columns.
Remaining exposure was written up rather than quietly closed off, so the next piece of work starts from a real picture.

Schematics

Row-level security policies on one table, scoped per command and per role
Xcode showing the Supabase manager with an authenticated client added alongside the anon client
55 PRODUCTION TABLES · LIVE PAYROLL AND GUEST DATA STAGE 01STAGE 02STAGE 03STAGE 04 ADDITIVESCOPEDPOLICIES APPRELEASEAUTH CLIENT DEVICEROLLOUTCONFIRMED REMOVEPERMISSIVEPOLICIES ZERO DOWNTIME SERVICE UP THROUGHOUT · NOBODY LOCKED OUT
DOCUMENTED RESIDUAL EXPOSURE PIN endpointNOT RATE LIMITED 12-hour JWTsNO REFRESH CYCLE RLS filters rowsNOT COLUMNS OPENOPENBY DESIGN
Four stages, sequenced so service never stops
Reporting

Weekly food & GP reporting

Weekly P&L every figure can be traced

PythonReportLabEPOS exports
No charge

I’ll find the money before you pay me anything.

Send me your software subscriptions and I’ll come back with what’s replaceable and what it’s worth — free, and yours to keep either way. How it works →

Contact

Want the same done to your cost base?

Open to operations, automation and technical operations roles — and to talking with anyone running a multi-site business who suspects they're paying for software they could own instead.