Skip to content
Skills Library
Security · Review & audit

multi-tenant-security

/multi-tenant-security

Verify tenant isolation in a multi-tenant SaaS — detect IDOR/BOLA, cross-tenant queries, filtering mistakes, leaky caches, jobs, files, search and exports — and enforce tenant scoping by design. Use whenever the app serves several organisations, teams, workspaces or customer accounts.

Licence
MIT
Last repository change
07.11.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 07.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Verify tenant isolation in a multi-tenant SaaS — detect IDOR/BOLA, cross-tenant queries, filtering mistakes, leaky caches, jobs, files, search and exports — and enforce tenant scoping by design. Use whenever the app serves several organisations, teams, workspaces or customer accounts.

Original author description

Verify tenant isolation in a multi-tenant SaaS — detect IDOR/BOLA, cross-tenant queries, filtering mistakes, leaky caches, jobs, files, search and exports — and enforce tenant scoping by design. Use whenever the app serves several organisations, teams, workspaces or customer accounts.

How it works

  1. Objectives
  2. Steps
  3. Security rules
  4. Validation criteria
Original SKILL.md headings · 49 lines, 432 words
SKILL.md preview
---
name: multi-tenant-security
description: Verify tenant isolation in a multi-tenant SaaS — detect IDOR/BOLA, cross-tenant queries, filtering mistakes, leaky caches, jobs, files, search and exports — and enforce tenant scoping by design. Use whenever the app serves several organisations, teams, workspaces or customer accounts.
---

# Multi-tenant security

Part of saas-blind-security — created and maintained by IbrahimCodeur.

## Objectives

- No user can read, modify, infer or delete data of another tenant through any channel.
- Tenant scoping is enforced centrally, not remembered per query.

## Steps

1. **Identify the tenancy model**: shared DB with `tenant_id`/`team_id`/`organization_id` columns, schema per
   tenant, DB per tenant, or packages (`stancl/tenancy`, `spatie/laravel-multitenancy`, `django-tenants`,
   Prisma middleware, PostgreSQL RLS). Write down where the *current tenant* comes from on each request
   (subdomain, path, header, session, token claim) and how it is validated against the user's memberships.
2. **Tenant resolution.** The tenant must be derived from the authenticated user's membership, never from a
   client-supplied value alone (header, query param, body field, subdomain) without a membership check.
3. **Central enforcement.** Prefer: Eloquent global scopes / tenant-aware base model, Django managers that
   require a tenant, ORM middleware, or PostgreSQL Row-Level Security with `SET app.tenant_id`. Then search for
   bypasses: `withoutGlobalScopes`, `withoutGlobalScope`, `.unscoped`, raw SQL, `objects.all()` in admin/API
   code, aggregate/report queries, `DB::table()` without scope.
4. **Object access.** Every by-ID lookup includes the tenant (or goes through the scoped relation). Check
   nested resources: `/projects/{p}/tasks/{t}` must verify `t` belongs to `p` *and* `p` to the tenant.
5. **Writes.** `tenant_id` set server-side, never mass-assignable; foreign keys pointing to another tenant's
   objects rejected (e.g. assigning a task to a user of another tenant).
6. **Side channels.** Caches keyed with tenant (`cache key = tenant:{id}:...`), queues/jobs carry and re-check
   the tenant, file storage paths namespaced per tenant with authorization on download, signed URLs short-lived,
   search indexes filtered by tenant, websockets/channels authorized per tenant, emails/notifications to the
   right tenant, logs and analytics not exposing other tenants, sequential IDs revealing customer counts.
7. **Admin & support tools.** Platform-admin access audited; impersonation limited and logged.
8. **Tenant lifecycle.** Tenant deletion removes or anonymises all data (DB, files, search, caches, backups per
   policy); tenant export contains only that tenant's data.
9. **Tests.** Create two tenants with one user each; for every endpoint and job, assert tenant A cannot access
   tenant B's resources (read, list, update, delete, export, search, file download).

## Security rules

- Treat any confirmed cross-tenant access as at least HIGH, usually CRITICAL.
- Never "fix" by filtering in the frontend or by hiding IDs.
- Do not use production tenant data in tests or reports.

## Validation criteria

- [ ] Tenancy model and tenant resolution documented.
- [ ] Scope bypasses (`withoutGlobalScopes`, raw queries, `unscoped`) listed and justified or fixed.
- [ ] Two-tenant automated tests cover all resource types and file downloads.
- [ ] Caches, jobs, storage and search verified for tenant namespacing.

Versions

The database has no other skills named multi-tenant-security.

Database snapshot: 13.11.2026 · package version d8d20be445c3 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100tenant-isolation
    Enforces tenant isolation in B2B SaaS on every path (web, API, jobs, caches, exports, webhooks, realtime): a fail-closed tenant context, scoped input IDs, scoping versus PostgreSQL RLS, cross-tenant probe tests. Use when adding a tenant-owned model, endpoint, job, cache key or…
  • 100api-access-control
    Detect and fix object-level and tenant-level access problems in APIs: cross-user access, IDOR/BOLA, mass assignment, unsafe API inputs, poor tenant isolation and unsecured endpoints. Use when reviewing REST/GraphQL/RPC endpoints or multi-tenant data access.
  • 85multi-tenant-isolation
    Test that a multi-tenant SaaS never leaks or mixes data between tenants (customers, companies, subsidiaries): ID guessing on APIs, list filters, search indexes, exports, caches, background jobs, file storage, reports and AI features. Use for any SaaS feature touching tenant…
  • 85multi-tenant-access-control
    Design, implement, or review tenant isolation and authorization across SaaS resources, roles, memberships, workers, caches, and administrative workflows. Use for access decisions or cross-tenant risks; skip authentication-only work and ordinary features with unchanged access boundaries.
  • 90nestjs-security-isolation
    Enforce multi-tenant isolation and PostgreSQL Row Level Security in NestJS. Use when enforcing tenant isolation or PostgreSQL RLS in NestJS multi-tenant apps.
  • 100cross-tenant-data-leak-tests
    Use when designing or adding tenant isolation tests to a multi-tenant app, adding a CI leak gate, or investigating a leak. Inventories tenant-bearing surfaces, then tests read-by-ID, list leaks, spoofed tenant IDs, JWT replay, storage IDOR, search, jobs and caches, plus Postgres row-level security.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.