Case study: when tenant isolation is a claim, not a control
On paper, the platform kept every customer’s data apart and needed two people to move money. In practice it did neither. This is how we found that out, proved it, and made the fixes stick.
LendStack is a multi-tenant lending platform we built to be deliberately vulnerable, then reviewed the way we would review a client’s system. It is a reference build, not a client engagement. It has three demo tenants, and the code, findings and evidence are public on GitHub.
The questions we set out to answer
A lending platform has to answer two questions with confidence: can one customer ever see or change another customer’s data, and can one person ever move money on their own? The code looked as though both were handled. It had database policies, tenant middleware and an approval step for transfers. We tested whether any of them actually worked.
Four findings, each proven against the running system
1. Database policies that never applied (Critical)
Row-Level Security policies were defined on every tenant table. But the application connected as the role that owned those tables, and in PostgreSQL a table’s owner skips its policies unless they are forced. With the connection set to one tenant, a single query returned invoice counts for all three tenants. After the fix, the same query returns one tenant’s row.
2. A files table with no tenant at all (High)
The table holding uploaded files had no tenant column, so nothing could filter it. Signed in as one customer, we requested another customer’s file by its ID and received it: the filename and its full storage path. After the fix, the same request returns 404, while the customer’s own files still load.
3. An export that skipped the tenant check (High)
The bulk export route was wired through the tenant middleware correctly. The code behind it then queried the database directly, around that middleware. One authenticated request returned:
GET /api/v1/admin/export
Before the fix: 15 invoices from 3 tenants
After the fix: 5 invoices from 1 tenant
4. Approvals that never compared two people (Critical)
Transfers recorded who created them and who approved them, but nothing checked that those were different people. One owner created a transfer and approved it, the API answered 204, and the database recorded it as self-approved. After the fix, the same attempt returns 403, a different user can still approve, and the database itself rejects any record where the creator and approver match.
The real problem was the design
Each bug could have been fixed on its own. The deeper issue was that every layer assumed another layer was doing the work. The application trusted the database policies, the policies trusted the application’s role, and the repositories trusted the middleware. When one layer failed silently, nothing caught it, and the system kept looking isolated while it leaked.
That is why our report named two layers for every finding: the one that failed, and the one that should have caught it.
Making the fixes stick
- Fix the layer where the problem lives. A schema gap got a schema change. A bypassed code pattern got a rule, not just a one-line patch.
- Ship every fix as a versioned database migration, numbered 001 to 004, so the before and after can be reproduced.
- Enforce prevention in CI. One check fails the build when a table lacks working row-level security. Another fails it when repository code skips the tenant-aware connection.
- Map each finding to the control it breaks, across PCI DSS 4.0, GLBA, SOX IT general controls and ISO 27001:2022, including the segregation of duties behind the approval gap.
- Retest everything, including the positive case, so the fix blocks the attack without breaking normal use.
What this shows about how we work
We prove findings with evidence from the running system, name the layer that failed and the one that should have caught it, and deliver the fix together with the check that stops it coming back. A Security Blueprint gives you the same view of your own platform.