cc-multi-tenant-safety

Audit multi-tenant applications for tenant isolation and authorization vulnerabilities.

1.0k|109|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/doccker/cc-use-exp --skill cc-multi-tenant-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cc-multi-tenant-safety
Source: https://github.com/doccker/cc-use-exp/tree/main/.codex/skills/cc-multi-tenant-safety
Command: npx skills add https://github.com/doccker/cc-use-exp --skill cc-multi-tenant-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Multi-tenant systems often leak data across tenants because developers trust request headers, forget tenant filters in queries, or rely on frontend-only feature gating. This Skill provides a systematic checklist of common isolation pitfalls with wrong/right code examples to prevent cross-tenant data access.

Core Features & Use Cases

  • Tenant Context Validation: Ensures tenant identity comes from the authenticated token, not spoofable request headers like X-Tenant-Code, with 403 responses on mismatch.
  • Query-Level Isolation: Detects unsafe findById/getReferenceById calls that bypass Hibernate @Filter or MyBatis interceptors, and enforces tenant-aware repository methods like findByTenantIdAndId.
  • Feature-Level Authorization: Distinguishes data isolation from functional authorization, requiring backend endpoint checks for tenant/role/subscription-gated features instead of hiding UI buttons.
  • Use Case: When reviewing a Spring Boot SaaS backend, apply the grep-based sniffing signals to find every naked findById in the service layer and verify each restricted endpoint independently validates tenant eligibility.

Quick Start

Review my multi-tenant Spring Boot service layer for tenant isolation issues using the cc-multi-tenant-safety checklist.

Frequently Asked Questions about cc-multi-tenant-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent cross-tenant data access in Spring Boot?

Derive tenant identity from the authenticated token rather than request headers, and validate header-supplied tenant codes against the token's tenantId. Add a global filter via Hibernate @Filter or a MyBatis interceptor so every query automatically includes the tenant_id condition.

Why does findById bypass Hibernate tenant filters?

Primary-key lookups like findById, getReferenceById, and findAllById go through the persistence context or second-level cache and skip entity @Filter conditions. Define tenant-aware methods such as findByTenantIdAndId on each repository and call those from the service layer instead.

Is hiding a button in the frontend enough for tenant-specific features?

No, frontend UI gating is only a user experience optimization, not a security boundary. Any logged-in user can call the endpoint directly, so the backend must independently validate tenant code, role, or subscription status and return 403 with a readable message.

How should the frontend handle a 403 tenant mismatch response?

The response interceptor should detect 403 responses whose message indicates a tenant mismatch, clear the login state, redirect to the login page, and show a clear toast message. Silently rejecting the promise leaves users on a blank page.

When should I use AOP or middleware instead of inline tenant checks?

Use a direct if check at the endpoint entry for one or two restricted endpoints since it is simplest and most readable. Introduce an annotation plus AOP, a Gin middleware factory, or a NestJS Guard only when three or more endpoints share the same restriction.