defensive-tenant-isolation

Enforce session-based tenant_id filters on Postgres and Supabase API routes.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/RideMatch1/a.e.g.i.s --skill defensive-tenant-isolation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: defensive-tenant-isolation
Source: https://github.com/RideMatch1/a.e.g.i.s/tree/main/packages/skills/skills/defensive/aegis-native/tenant-isolation-defense
Command: npx skills add https://github.com/RideMatch1/a.e.g.i.s --skill defensive-tenant-isolation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-tenant data leakage and insecure access patterns in multi-tenant SaaS apps, caused by using tenant_id from user input or missing tenant scoping.

Core Features & Use Cases

  • Server-side primitive: secureApiRouteWithTenant ensures tenant_id comes from the authenticated session and is applied to all queries.
  • Anti-patterns and remediation: guides developers away from trusting request body or query params for tenant_id and demonstrates secure patterns.
  • Regression testing: provides test patterns to verify tenant isolation invariants across endpoints and data.

Quick Start

Install the AEGIS tenant-isolation patterns and start using secureApiRouteWithTenant in your API routes.

Frequently Asked Questions about defensive-tenant-isolation

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

FAQPage Schema
How do I prevent cross-tenant data leakage in a multi-tenant SaaS application?

Prevent cross-tenant data leakage by enforcing tenant_id filters derived strictly from the user session rather than request input. Applying session-based tenant injection to all API routes and data access layers ensures consistent tenant scoping across endpoints.

Why does trusting tenant_id from request body or query params cause insecure API access?

Trusting tenant_id from request body or query params causes insecure API access because client-supplied values can be tampered with to bypass isolation. Secure patterns require extracting tenant_id directly from the authenticated JWT session to guarantee data ownership.

How do I enforce tenant isolation in Postgres or Supabase data access layers?

Enforce tenant isolation in Postgres or Supabase data access layers by applying a server-side primitive that injects session-derived tenant_id filters into all database queries. This prevents users from accessing records outside their assigned tenant scope.

Can I use regression testing to verify multi-tenant isolation invariants across my API endpoints?

Yes, you can use regression testing to verify multi-tenant isolation invariants. Implementing dedicated test patterns across endpoints and data layers validates that session-based tenant scoping remains intact and prevents cross-tenant data leakage during future updates.

What is the best way to secure API routes for multi-tenant applications without relying on user input?

The best way to secure API routes for multi-tenant applications is using a server-side primitive like secureApiRouteWithTenant. This mechanism enforces session-based tenant injection and applies anti-pattern remediation guidance to ensure tenant_id is never sourced from user input.

When do I need to apply secureApiRouteWithTenant in my multi-tenant SaaS endpoints?

Apply secureApiRouteWithTenant whenever your multi-tenant SaaS endpoints manage shared Postgres or Supabase databases. It is required for API routes, data access layers, and test suites to ensure consistent tenant scoping and prevent cross-tenant data leakage.