Retrospective
What I Would Build Differently, and What That Taught Me
Section 4 of 4
This is the oldest substantial project in this portfolio, and the most useful thing I can do with it is not defend it. Its breadth is genuine — four applications, a real inventory and costing chain, a working multi-tenant operator console. Its authorization model is wrong in a way I did not understand at the time and would never ship now.
Both of those facts are worth more together than either alone. Anyone can list what they built. The more informative question is whether they can look at their own earlier work and say precisely what is wrong with it, which is the difference between having had five years of experience and having had the same year five times.
The Core Mistake
Tenant-scoped endpoints take the tenant's identity from the URL and filter on it, with no middleware verifying that the caller is that tenant. The fix is not a better filter — it is never letting the caller state who they are.
The query is correctly scoped. Asking for an account's orders returns that account's orders and nobody else's, which looks like isolation and is why this pattern survives review so often.
What it is missing is the other half. Filtering determines which records a request touches; authorization determines whether the request may touch them at all. Taking the tenant from the URL collapses those two questions into one and answers only the first, so the caller is effectively asked who they would like to be and then believed.
In practice an attacker needs one piece of information they are not supposed to be prevented from having — a venue's email address — and they can read that venue's orders, revenue, menus and QR configuration. The front end never offers the option, which is exactly why it felt safe. The front end is not what makes the request.
The correction is structural rather than a patch per endpoint: authentication middleware ahead of every tenant-scoped route, resolving the tenant from the verified session and passing it to the handler, so no handler ever reads a tenant identifier out of a request. Done that way the vulnerable version becomes unwriteable, because there is nowhere to put the mistake.
Where this went next
The authorization lesson on this page is the direct ancestor of the QuickFix security rules, where every access decision is resolved server-side and an agent claiming work from a pool can only ever assign it to themselves. Reading the two together is the clearest picture of how my thinking on this changed.