Tenant deletion cascades completely
Why it matters
Incomplete tenant deletion leaves orphaned records that violate both contractual data-isolation guarantees and GDPR Art. 17 (Right to Erasure). CWE-404 (Improper Resource Shutdown or Release) covers the defect. Orphaned records create concrete risks: a future tenant who is assigned a recycled UUID can inadvertently access predecessor data; orphaned API keys remain valid credentials; and billing records for deleted tenants create accounting liabilities. The ISO 25010 functional suitability requirement is simple — delete means delete.
Severity rationale
High because orphaned records after tenant deletion expose residual data to future tenants or direct lookups, and violate GDPR Art. 17 erasure obligations.
Remediation
Use database cascade deletes as the primary mechanism and supplement with explicit cleanup for external systems. In schema.prisma, add onDelete: Cascade on every relation to Organization:
model Project {
id String @id
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
}
For external data, implement a cleanup routine in src/app/api/orgs/[id]/route.ts:
async function deleteOrganization(orgId: string) {
await db.organization.delete({ where: { id: orgId } }) // cascades handle DB relations
await deleteS3Prefix(`tenants/${orgId}/`)
await algolia.deleteBy({ filters: `organizationId:${orgId}` })
await redis.del(`tenant:${orgId}:*`)
}
Wrap the DB delete and cleanup in a transaction or saga pattern so a failed external cleanup triggers a retry, not a partial deletion state.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Multi-Tenancy Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-404 — Improper Resource Shutdown or Release
- gdpr · Art. 17 — Right to Erasure
- iso-25010:2011 · functional-suitability — Functional Suitability
- soc2:2017 · C1.2 — Disposal of confidential information
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-multi-tenancy·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (C1.2) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2