Invental/Review lessons/Trust boundaries the server must hold

Trust boundaries the server must hold

Shared tables need row rules in code

When two features share one table, enforce “who may touch which rows” in code. Then check every read path that skips your service (joins, counts) as well: editable permission presets don't stop new or retyped rows.

01 · Before and afterThe pattern

TypeScript
// service: writes
if (!isAdmin(acc) && (data.type ?? 'files') !== 'files') throw new ForbiddenError();
if (!isAdmin(acc) && await isAutomationFolder(data.parent)) throw new ForbiddenError();
// reads, plus every path that skips the service (counts, joins)
if (!isAdmin(acc)) query.filter = and(query.filter, { type: { not: 'automations' } });

02 · Run it on your appThe check

If a table now holds rows for two features, can a user with access to one feature reach the other's rows through a join, a count, or a type change?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.