/viperclaw:viper-multitenant-isolationfrom viperclaw
Audits multi-tenant SaaS apps for data isolation issues: tenant context propagation, ORM query scoping, shared cache keys, and background job isolation. Checks PostgreSQL RLS, JWT tenant binding, and async context safety.
Ships in viperclaw. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
viper-multitenant-isolation)viper_taint_scan, viper_diff_oracle, viper_verify_and_reportviperclaw taint ./src --db .viperclaw/graph.dbflowchart LR
Auth["Verified JWT / Session Tenant ID"] --> Ctx["Request-Scoped ContextVar + DB RLS"] --> Store["Tenant-Prefixed Cache / S3 / Vector Index"] --> Worker["Signed Tenant Context in Async Jobs"]
Cross-tenant data leaks in SaaS platforms happen when tenant_id is read from a request header/body instead of the verified session, when a global/singleton variable stores current_tenant across concurrent async requests, when Redis cache keys omit the tenant_id prefix, or when PostgreSQL RLS is enabled without FORCE ROW LEVEL SECURITY (allowing table owners to skip RLS enforcement).
Run the following discovery commands across the target repository before manual code review:
# 1. Automated ViperClaw analysis
viperclaw taint ./src --db .viperclaw/graph.db
# 2. Rapid static pattern discovery (ripgrep)
rg -n "(tenant_id|org_id|organization_id|workspace_id|account_id)"
rg -n "(current_setting\(.app\.current_tenant|ENABLE ROW LEVEL SECURITY|FORCE ROW LEVEL SECURITY)"
rg -n "(redis\.(get|set)|cache\.(get|set))" ./src
| Control ID | Audit Verification Target | Pass Criteria | Fail / Vulnerability Indicator |
|---|---|---|---|
MT-01 | Cryptographic Tenant Context Binding | tenant_id is derived exclusively from the verified session/JWT or verified membership table—never from an unverified X-Tenant-ID header. | Middleware reads req.headers['x-tenant-id'] without checking if current_user belongs to that tenant. |
MT-02 | PostgreSQL RLS + FORCE ROW LEVEL SECURITY | Every multi-tenant table enables both ENABLE ROW LEVEL SECURITY and FORCE ROW LEVEL SECURITY with current_setting('app.tenant_id', true). | Application connects as the table owner without FORCE ROW LEVEL SECURITY, silently skipping all RLS policies! |
MT-03 | Connection-Pool Tenant Context Reset | Transaction-scoped SET LOCAL app.tenant_id = ... is used (or DISCARD ALL on pool checkout/checkin) so pooled connections never bleed tenant context. | Session-level SET app.tenant_id persists on a PgBouncer/SQLAlchemy pooled connection for the next request. |
MT-04 | Async Coroutine Context Isolation (ContextVar) | In Python/Node async servers, tenant state is stored in contextvars.ContextVar / AsyncLocalStorage, never on a module global or class singleton. | Singleton service attribute self.tenant_id = ... overwritten by concurrent coroutine from another tenant. |
MT-05 | Tenant-Namespaced Cache Keys (Redis / Memcached) | Every cache key includes tenant:{tenant_id}:... (@cache decorators include tenant_id in the key hash). | @lru_cache or redis.get(f'report:{report_id}') serves Tenant A's cached report to Tenant B. |
MT-06 | S3 / Object Storage Prefix & KMS Isolation | Object keys enforce s3://bucket/{tenant_id}/{uuid} and IAM/presigned policies restrict access to that prefix. | Flat S3 bucket path allowing cross-tenant key guessing or overwrite. |
MT-07 | Search & Vector Index Tenant Filtering | Elasticsearch, Algolia, and vector DB queries inject a mandatory server-side tenant_id filter. | Global search autocomplete leaks document titles or user names from other tenants. |
MT-08 | Background Job Tenant Re-Validation | Celery/BullMQ tasks receive tenant_id + actor_id and re-verify membership before executing exports or webhooks. | Background export job runs raw unscoped SQL without setting the tenant RLS context. |
| Severity Tier | Baseline CVSS v3.1 Vector | Qualifying Security Impact |
|---|---|---|
| CRITICAL (9.3) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N | Unverified X-Tenant-ID header or pooled connection state bleed granting full access to any tenant's data. |
| HIGH (8.1) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N | Unscoped Redis cache key or search index leaking cross-tenant reports or PII. |
| MEDIUM (6.5) | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:N | Async coroutine race condition occasionally returning another user's response under high load. |
-- ❌ VULNERABLE: Missing FORCE ROW LEVEL SECURITY (table owner skips RLS!) & session-wide SET
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoices USING (tenant_id = current_setting('app.tenant_id')::uuid);
-- ✅ HARDENED: Enforces FORCE ROW LEVEL SECURITY + WITH CHECK on INSERT/UPDATE
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
ALTER TABLE invoices FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoices
FOR ALL
USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::uuid)
WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::uuid);
viperclaw taint and viperclaw verify to confirm zero remaining unmitigated flows in .viperclaw/graph.db.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub zahidoverflow/viperclaw --plugin viperclaw72 skills in this plugin
/viper-agent-skill-supplychainAI Agent Skill, Plugin & MCP Config Supply-Chain Auditor (modeled on NVIDIA SkillSpector & OWASP Agentic Skills Top 10). Audits SKILL.md bundles and MCP JSON configs./viper-ai-llm-guardrailsAI, LLM & MCP Application Security & Guardrails Auditor (OWASP LLM Top 10). Reviews prompt boundaries, RAG data isolation, tool-call authorization, and output sanitization./viper-api-gateway-apigee-kongAPI Gateway, BFF & Rate-Tier Policy Auditor (Kong, AWS API Gateway, Apigee, Envoy Gateway). Reviews JWT authorizers, backend origin lockdown, and route-level quotas./viper-auth-oauth-jwtAuthentication, OAuth 2.0 / OIDC & JWT Security Auditor. Reviews token verification, algorithm allowlisting, claim validation, and OAuth redirect_uri configurations./viper-aws-iam-cloud-auditAWS IAM, STS, S3, KMS & Lambda Security Auditor (modeled on Prowler, Parliament & CloudSplaining). Reviews iam:PassRole escalation, STS ExternalId, S3 policies, and IMDSv2./viper-bola-idorObject & Function-Level Authorization (BOLA / BFLA) Audit Skill. Reviews resource access controls, tenant scoping, and ownership checks across API endpoints and controllers.Other plugins' skills for the same job