Resource 02 · Data isolation

Row-level security auditor

Inventory user and tenant data, trace every access path, and identify tables or queries that can cross an isolation boundary.

Copyable AI skillPracticalYours to use

What it examines

A focused review with evidence boundaries.

The skill is intentionally read-only. It separates confirmed findings from missing evidence and never treats an absent file as proof that a control exists.

01

User and tenant-bearing tables

02

Database policies and grants

03

Service-role or administrator bypasses

04

API and server query filters

05

Storage-object policies

06

Background jobs and exports

Run the skill

Paste it into your AI coding assistant.

Open the repository in your preferred coding assistant, give it read access to the project, then paste this instruction. Review its evidence before acting on any recommendation.

Download .md

Act as a database and application-security engineer auditing tenant isolation in this repository. Work read-only. Do not alter policies, schemas, data, credentials, or infrastructure; do not query production; and never print real records or complete secrets.

Goal: determine whether a user from tenant A can read, create, update, delete, infer, export, cache, or trigger side effects against tenant B's data through any supported or accidental path.

Investigation procedure
1. Map identity. Identify the authentication provider, server-side identity verification, authoritative user ID, authoritative tenant/account/workspace ID, membership model, role model, invitation flow, impersonation/support paths, and how tenant context is selected. Cite evidence.
2. Map protected data. Inventory every table, view, materialized view, collection, bucket/path, search index, cache keyspace, queue payload, analytics destination, export, and backup reference that contains tenant- or user-owned data. Record the ownership key and whether it may be null or reassigned.
3. Map enforcement layers. For each resource, inspect database policies and grants, application query scopes, API authorization, RPC/stored procedures, ORM middleware, serverless functions, storage policies, search filters, cache keys, and downstream integration scopes. Presence of a tenant_id column is not enforcement.
4. Trace every operation. Follow list, detail, create, update, delete, bulk action, file access, search, export, report, webhook, background job, scheduled task, admin/support tool, and service-to-service path from untrusted input to the final data operation.
5. Challenge tenant context. Flag any path where user_id, tenant_id, organization_id, role, object key, filter, or storage path is accepted from the client without being re-derived and authorized server-side. Treat UI filtering and hidden fields as no control.
6. Inspect privileged execution. Find service-role/admin database clients, SECURITY DEFINER functions, bypass-RLS roles, elevated API keys, maintenance jobs, imports, and analytics workers. For each, prove how scope is constrained before execution.
7. Inspect database-policy semantics where applicable: RLS enabled and forced, USING and WITH CHECK coverage, command-specific policies, joins and helper functions, ownership/bypass behavior, grants, views, functions, and migration parity. Note policy recursion or performance hazards that could cause teams to disable enforcement.
8. Inspect indirect leakage: predictable IDs, counts, error differences, signed URL reuse, cache collisions, logs, notifications, emails, exports, webhooks, search results, and object metadata.
9. Review tests. Look for two-user and two-tenant negative tests at the database/API boundary, not only mocked UI tests. Do not execute destructive integration tests. Propose safe fixtures when the repository lacks them.

Classification
- CONFIRMED ISOLATED: enforcement and a negative test prove the boundary.
- PARTIAL: enforcement exists but a path, operation, or privileged role is not covered.
- CONFIRMED BYPASS: a realistic cross-tenant path is evidenced.
- NOT VERIFIED: required code, policy, environment, or test evidence is unavailable.

Severity
- Critical: unauthenticated or ordinary-user cross-tenant access to sensitive data, writes, money, permissions, or bulk exports.
- High: bypass requiring a common elevated workflow, predictable identifier, job, file path, cache, or weak administrative path.
- Medium: limited metadata leakage, missing negative tests around otherwise consistent enforcement, or risky defense-in-depth gap.

Output exactly these sections
1. Verdict and attack narrative — state whether isolation is proven and describe the shortest credible tenant-A-to-tenant-B path.
2. Identity and tenant model — authoritative identifiers, membership/roles, tenant selection, privileged actors, evidence.
3. Isolation matrix — resource, ownership key, operations, enforcement layer, bypass role, state, evidence, missing proof.
4. Findings — severity, precise path, file/line or policy evidence, exploit prerequisites, affected data/action, remediation.
5. Negative-test plan — executable test cases for list/detail/create/update/delete/search/files/exports/jobs/admin; include setup, action, and expected denial. Use two users in two tenants plus same-tenant controls.
6. Repair sequence — smallest safe changes in dependency order, including data backfill or migration risk, rollout, and rollback.
7. Verification checklist — exact safe commands, policy queries for a non-production database, and acceptance criteria needed to change each PARTIAL or NOT VERIFIED result to CONFIRMED ISOLATED.

Do not infer isolation from framework conventions. Do not recommend RLS as a slogan: specify the exact enforcement point and the application paths it must cover. Separate confirmed vulnerabilities from hypotheses and evidence gaps.

Expected output

A decision-ready result, not a vague code review.

Use the result as a starting point. High-risk findings still need human review before production changes are made.

  1. 01A table-by-table isolation matrix
  2. 02Confirmed bypass paths with evidence
  3. 03Queries that rely on UI filtering or caller-supplied tenant IDs
  4. 04Missing negative tests for cross-tenant access
  5. 05A repair and verification plan

Choose the next useful step

Use the result to ask a better engineering question.

The skill gives you a structured first pass. A senior review turns the evidence into an accountable decision.

Scroll to Top