Skip to content
Back to skills

Multi Tenant Saas

ASecurity

In an aidd repository, use when code touches tenant IDs, organizations, workspaces, row-level security, tenant isolation, shared databases, or per-tenant keys.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 6, 2026
ai-agentsgosqlawsazuregitapidatabasesecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 17, 2026

npx -y skills add thaithienvanid/aidd --skill multi-tenant-saas --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Multi Tenant Saas?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Multi Tenant Saas
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thaithienvanid-multi-tenant-saas/badge)](https://www.skillsdirectory.com/skills/thaithienvanid-multi-tenant-saas)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: multi-tenant-saas
description: "In an aidd repository, use when code touches tenant IDs, organizations, workspaces, row-level security, tenant isolation, shared databases, or per-tenant keys."
---

<!-- generated by `aidd gen-docs` from schemas/packs.json; edit the registry, not this file -->

# Multi-tenant SaaS

## Scope

Applies when the change touches code that reads or writes data belonging to a tenant, organization, workspace, or customer account in a shared deployment. Not when each customer runs its own deployment and database. Neighbours: `aidd-domains:enterprise-controls`, `aidd-domains:apis-and-services`, `aidd-team:threat-model`.

## Standards

| # | Standard | Edition | Checked | Source |
| --- | --- | --- | --- | --- |
| S1 | OWASP API1:2023 Broken Object Level Authorization, applied across tenants | 2023 | 2026-11-10 | <https://api-security.owasp.org/editions/2023/en/0x11-t10/> |
| S2 | SaaS tenant isolation guidance (AWS Well-Architected SaaS Lens; Azure's multitenant architecture guide agrees): isolation, noisy neighbours, and tenant cost | 2023-04-04 | 2026-10-16 | <https://docs.aws.amazon.com/wellarchitected/latest/saas-lens/saas-lens.html> |
| S3 | PostgreSQL row security policies as a second layer of tenant isolation | PostgreSQL 18, section 5.9 | 2026-10-16 | <https://www.postgresql.org/docs/current/ddl-rowsecurity.html> |
| S4 | EU Data Act: access to connected-product data, and switching between data processing services | Regulation (EU) 2023/2854 | 2026-10-22 | <https://eur-lex.europa.eu/eli/reg/2023/2854/oj> |

## Dated obligations

| From | Obligation | Standard |
| --- | --- | --- |
| 2027-01-12 | EU Data Act Art. 29: no switching charge, data egress included. Until then, a charge is at most the direct cost of the switch. | S4 |

## Checklist by loop step

| Step | Item | Standard |
| --- | --- | --- |
| Before the first edit (`aidd risk --paths`) | Name every table, bucket, cache key, queue, and search index the change touches that holds tenant data. A new one without a tenant key is a design question before Specify. | S2 |
| Before the first edit (`aidd risk --paths`) | Where tenants hold their own keys, each tenant's data is encrypted under its key. A key the tenant revokes makes its data unreadable, and offboarding destroys the key. | S2 |
| Specify | Acceptance states that a client of tenant B cannot read, list, update, or delete tenant A's data through each changed operation. It names the expected response (404, not 403, where existence must not leak). | S1 |
| Specify | Every cross-tenant query (billing roll-ups, support tools, analytics) is named in the Spec. It runs under a separate role or service and is unreachable from customer-facing endpoints. | S2 |
| Specify | Each tenant-facing operation has a per-tenant quota or rate limit by tier (requests, storage, jobs), so one tenant cannot starve the rest. The Spec names the limit and the answer past it (429 with Retry-After). | S2 |
| Specify | Offboarding: a tenant's data can be exported in a documented format, then deleted from every store within a stated period. The stores: tables, replicas, caches, search, and object storage; backups as they expire. Switching under the EU Data Act: a notice period of at most two months, a transition of at most 30 days, and every exportable data and digital asset exported. | S2, S4 |
| Implement | The tenant id comes only from the authenticated token or session. It never comes from the request body, the query string, a path parameter, or a header the client sets. | S1 |
| Implement | Tenant scoping lives in the data-access layer, in a base query or repository that every read and write goes through. A check after fetching the row is a finding, not a control. | S2 |
| Implement | Every joined or sub-queried table is filtered by the tenant id again. Cache keys, object-storage paths, search queries, queued jobs, events, and log lines carry the tenant id, and a worker sets the tenant context before its first query. | S2 |
| Implement | Row-level security (or the database's equivalent) enforces the same scoping as a second layer, with the application connecting under a role that cannot bypass it. | S3 |
| Review | Trace each changed query to its tenant filter. Any raw query, bulk job, or new join without one, and any tenant id read from client input, is a finding. | S1 |
| Review | A user in many tenants holds a token for one active tenant, and switching clears the client's cached data. Support access to a tenant's data is time-bound, granted where the contract says, and logged. | S1 |
| Roll out | Cross-tenant access denials and any query that runs without a tenant context are logged and alerted on during the observe window. | S2 |
| Learn | Cost per tenant is measured (tags, metering, or usage attribution) and reported by tier as unit economics. A tier whose cost per tenant exceeds its price is a Learn action. | S2 |

## Test commands

| Command | Proves | How | Standard |
| --- | --- | --- | --- |
| Cross-tenant read test per data-access method | client B cannot see, list, or change client A's records through any repository method or endpoint the change touches | a parameterized test that seeds two tenants and calls every data-access method and endpoint as tenant B against tenant A's ids, in the repository suite | S1, S2 |
| Tenant id from client input is ignored | a tenant id placed in the body, query, path, or a header does not change which tenant's data is returned | API tests that send tenant A's id in each position with tenant B's token and assert tenant B's scope | S1 |
| Row-level security enforced | the database refuses cross-tenant rows even when the application filter is missing | on PostgreSQL, a test connects as the application role, sets tenant A's context, and runs an unfiltered `SELECT` on each tenant table, expecting only A's rows. It checks that a pooled connection reused after a transaction carries no tenant, and a migration test checks `FORCE ROW LEVEL SECURITY`. On another database, the same test runs against its row-level security | S3 |
| Unscoped query lint (emerging) | no query on a tenant table bypasses the scoped base query | a Semgrep rule (`uvx semgrep==1.180.0`), or the ORM's own check, that flags raw queries and direct model access on tenant tables outside the data-access layer | S2 |
| Per-tenant quota enforced | a tenant past its limit gets 429 with Retry-After while another tenant's requests still succeed | a load test with one scenario per tenant, in the runner `apis-and-services:load-test` names (default k6). It drives tenant A past its tier's limit and asserts that tenant B's success rate and p95 hold | S2 |
| Tenant offboarding export and delete | a tenant's export holds all its records, and after deletion no store returns any of them | a test that seeds two tenants, exports A, and compares it with the seed. It then deletes A, looks up A's ids in every tenant store (tables, caches, search, object storage), and finds none, with B untouched | S2 |

## Owned elsewhere

- Data residency, and the enterprise-deal controls such as SSO, SCIM, and the audit log: `aidd-domains:enterprise-controls`.
- The processor contract and the notice of a new sub-processor: `aidd-domains:privacy-by-default`.

## References

- [references/open-choices.md](references/open-choices.md): its open choices, with aidd's defaults.

## Keep it current

Each entry is due after its `review_every_days` (else emerging 90 days, established 365) or by its `review_due`. An emerging one applies only when the change needs it, said in the Spec. One `aidd eval standards` lists as due is looked up in Specify, and a missing one is proposed to aidd's `schemas/industry-standards.json`.

Files in this skill

  • SKILL.md7.5 KB
  • references/open-choices.md854 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.