· 4 min read
Tenant isolation in four layers, and the list that checks it
Why TimeUp does not rely on row-level security alone, how four layers fit together, and what a frozen list of 314 handlers does and does not prove.
In July an audit found a consent-template endpoint that accepted an id without checking whose it was. In a system where many businesses share one database, that is a leak waiting for someone to pass the right id.
Four layers
Who you are is re-read from the database on every request; the token only carries an id and a version. The chosen business travels in a signed cookie that is a hint, checked against active memberships each time. The database rejects cross-business references with composite foreign keys. And row-level security is on for every table with no policies, as a last backstop.
Why not lean on row-level security
The app connects as the schema owner, which bypasses it. Calling that the main defence would be theatre: application authorization is what decides, and the database rules are the net underneath.
…
A list that can fail
A census pins 314 API handlers to the permission each one requires. A static check reads every route and fails if a database or storage call appears before the permission check. When new owner handlers were added without it, the census caught the gap, not a reviewer.
What it does not prove
The tenant guard checks that every query on a per-business model carries a business filter. Today it enforces in development and tests, for twelve models; in production it only observes. It checks that a filter is present, not that it is the caller's, and raw SQL is outside it.
The census shows the permission check comes first, not that it is the right one. None of this proves isolation by construction.