Skip to content
Blogs

Permission Models for Multi-Tenant AI Copilots

· 21 min read

A copilot that inherits chat access but skips data ACLs will quote the wrong tenant with confidence. Staff engineers route every tool call through the same authorization path as REST handlers, partition retrieval by tenant, issue short-lived scoped credentials, and test cross-tenant denial continuously—not only in demos.

Chat access is not data access

Users who can open a copilot panel must not automatically read every document the model can retrieve. Separate conversation membership from resource entitlements. The model sees only what a server-side policy allows for that principal in that tenant—never what a prompt claims the user needs.

Cross-tenant leakage often starts in retrieval: embeddings indexed without tenant predicates, or shared vector collections queried by similarity alone. Put tenant id in every index partition, every cache key, and every tool argument validation.

Product copy that says "you can ask anything" is not a permission model. Engineering must map each UI surface to an explicit principal, tenant, and data scope before the first production tenant onboarded with real customer documents.

Mobile clients that embed copilots still execute tools on the server. Expo UI permissions do not replace row-level checks in Postgres or object ACLs in storage buckets.

Document a data classification matrix: which document types each role may retrieve, which tools may mutate them, and which fields must be redacted before they enter the model context. Without that matrix, product and legal debate permissions in Slack while engineering ships a generic search tool.

Conversation history is also data: exporting threads for fine-tuning or eval must respect the same tenant boundaries as live retrieval. A leaked export bundle hurts compliance even when production chat UI behaved correctly.

Authorize tools like public APIs

Every tool invocation should pass through the same authz middleware as your REST or gRPC handlers: authenticate the user or service identity, resolve tenant context, check RBAC or ABAC, then execute with least privilege. Agents must not hold long-lived god tokens that bypass row-level checks.

Prefer short-lived, scoped credentials issued per session or per tool call. When agents fan out, propagate subject and tenant claims—do not widen scope because a planner step "needs more context."

| Layer | Must enforce | Common miss | | --- | --- | --- | | Tool router | Tenant + role | Trusting model-chosen ids | | Downstream API | Resource ACL | Shared service account | | Vector index | Partition filter | Global similarity search | | Audit log | Principal + decision | Logging prompts only |

Shadow permission paths appear when teams add a "fast" internal endpoint for agents only. That endpoint becomes the exfil route the moment prompt injection learns its name.

Rate-limit tool calls per tenant and per user to slow brute-force guessing of resource ids. Authorization bugs plus high QPS often show up as support tickets about "random documents" before security teams get paged.

OAuth scopes presented to third-party integrations should not automatically grant copilot tools. Users confuse "connect Google" with "let the model read every shared drive" unless the consent screen names exact data classes.

Model the principal the agent acts as

Decide whether the copilot acts as the end user, as a constrained assistant role, or as a break-glass operator with separate approval. Document the difference for support and compliance. Impersonation without audit is a security incident waiting to happen.

Prompt injection can try to elevate tools. Defense is policy enforcement outside the model: deny lists, allow lists of tools per role, and output filters that cannot grant new permissions.

Break-glass flows need dual control: a human approver, a time box, and a distinct audit stream. Agents should not inherit admin APIs because a support ticket was urgent.

For B2B SaaS, map each customer admin role to a tool profile. Resist "one copilot profile for all roles" unless your smallest customer truly matches your largest enterprise contract.

Guest and contractor identities need explicit expiry. Copilots that remember old contractors through stale JWT claims or cached retrieval bundles create compliance findings faster than feature wins.

Retrieval filters and index design

Hybrid search without tenant filters is a data breach at scale. Metadata filters must be mandatory, not optional query hints the model can omit. Validate filter presence in the retrieval service before executing vector or keyword queries.

Re-embed documents when tenant moves between organizations are impossible—design ids so reindexing is explicit. Shared embedding models are fine; shared logical collections across tenants are not unless cryptographic isolation proves otherwise.

Cache retrieval bundles with keys that include tenant, principal hash, and document revision. Personalized answers cached without principal in the key leak across users sitting behind the same NAT.

Log retrieval hits with resource ids and denial reasons. Spikes in "empty result" after deploys often mean a broken filter, not smarter users.

When hybrid search blends keyword and vector scores, apply tenant filters before ranking—not after top-k is chosen. Post-filtering top results still leaks metadata timing side channels in careful attacks; pre-filtering is the default safe pattern.

Reindex jobs must tag documents with tenant and sensitivity at ingest time. Backfills that import years of files without metadata force engineers to choose between blocking copilot launch and guessing ACLs from folder names.

Supabase RLS and tool gateways

```sql -- Every copilot query uses the end-user JWT, not the service role create policy tenant_docs_select on documents for select using ( tenant_id = (auth.jwt() ->> 'tenant_id')::uuid and has_role(auth.uid(), 'reader') );

-- Tool gateway sets request.jwt.claims before SQL ```

Service role keys belong in the tool gateway, not in the model context. The gateway validates tool input, swaps to user-scoped credentials, runs SQL or edge functions, and returns redacted results.

Edge functions that call LLMs should accept tenant and user from verified session middleware—never from raw JSON the model produced. Treat model output as untrusted input to the next hop.

When MVPs skip RLS "temporarily," copilots accelerate the day tenant B reads tenant A rows. Ship RLS before ship copilot, or ship copilot read-only on public data only.

Storage buckets for uploads need the same tenant prefix discipline as database rows. Tools that generate signed URLs must include tenant and object ACL checks, not only obscurity of object ids.

Prompt injection versus policy engine

Instructions cannot revoke database permissions. Classifiers reduce obvious abuse; they do not replace authorization. Place allow/deny decisions in code the model cannot edit: tool registry, capability tokens, and retrieval guardrails.

Test injection strings that ask the model to ignore policy, call admin tools, or re-label tenant ids in arguments. Automated suites should assert denials, not only polite refusals in natural language.

Separate "helpful tone" prompts from "capability" prompts. Tone belongs in the model; capabilities belong in signed tool manifests loaded server-side per session.

Red-team with multi-step plans: retrieve a public doc, then ask the model to rewrite tool args for another tenant id. Policy must reject at the gateway even when the chat transcript looks innocent.

Keep a library of injection fixtures versioned beside tool schemas. When a new tool ships, add fixtures before enablement—not after the first customer pen test.

Human reviewers approving break-glass sessions should see the proposed tool list and resource scope in plain language—not only the model summary. Elevation requests that hide technical scope fail audits even when outcomes were benign.

Prove isolation continuously

Add automated tests that attempt cross-tenant retrieval and tool calls with stolen conversation ids. Monitor denial rates and unexpected allow spikes after prompt or index changes. Multi-tenant copilots fail loudly in demos and quietly in production—instrument for the quiet failures.

Run periodic chaos exercises: rotate JWT signing keys, break a filter, verify alarms fire before customer reports. Permissions regressions often ship as "small refactors" to the tool router.

Permissions are product surface. Design them with the same care as the model that speaks behind them—especially when sales promises "AI for every seat" before engineering finishes tenant profiles.

Pair with containment architecture: even perfect ACLs fail if the agent runtime can exfiltrate via unrestricted egress. Authorization and containment are complementary, not interchangeable.

Export denial metrics to the same dashboard as model latency. Security regressions hide when teams only watch token throughput and ignore allow/deny ratio drift.

Pen testers should receive tenant fixtures that mirror production org shapes—not single-tenant demos with synthetic data only. Realistic hierarchy exposes role mapping bugs generic tenants miss.

Operational checklist for copilot authorization

Maintain a tool catalog listing each tool, required roles, data classes touched, and whether break-glass applies. Pull requests that add tools must update the catalog or fail CI.

Publish which identity each environment uses for eval and staging—never point eval agents at production tenants with service credentials "for speed."

Review audit logs weekly for allow decisions on sensitive tools. Zero denials for a week on a high-risk tool often means logging broke, not perfect users.

Link copilot incidents to missing authz tests the same way you link outages to missing integration tests. When a tenant reports leakage, add a regression that fails until the filter is mandatory.

Finally, train support to recognize "the AI saw my file" reports as authorization bugs until proven otherwise. Copilots make silent ACL misses visible as trust incidents overnight.

Schedule quarterly access reviews for break-glass tool profiles the same way you review admin accounts. Copilots increase the number of effective admins without increasing headcount—governance must catch up.

Align copilot launch checklists with mobile and web release gates: no new tool without authz tests, no index change without tenant filter verification, no prompt update without injection regression on critical tools.

Customer success templates should never instruct admins to paste service keys into copilot settings. If onboarding docs mention keys, security review blocks the publish—the same way you block committed secrets in git.

Treat copilot permission regressions as Sev-2 when production tenants share industries or supply chains—competitive leakage is a board-level story, not a support macro.

Run tabletop exercises with legal and support: walk through one cross-tenant leak from detection to customer notification. Copilots compress time from bug to headline when answers quote real competitor data. Rehearse before launch week, not after press interest. Document owners for each step in the security incident runbook. Update it quarterly after org or tool changes.

Frequently asked questions

Is chat membership enough to gate retrieval?
No. Conversation access only proves the user can open the UI. Retrieval and tools must enforce tenant and resource ACLs independently. Many leaks happen because retrieval indexes omitted tenant predicates while chat auth succeeded. Treat data access as a separate decision logged on every query.
Can agents use the Supabase service role for speed?
Not for user-scoped copilot actions. Service role bypasses RLS and belongs in tightly controlled batch jobs, not interactive tool loops driven by model output. Use user JWTs or narrowly scoped service identities per tool with explicit tenant binding and short TTL.
Why route tools through existing API middleware?
Duplicating authz in agent-specific code creates shadow paths that prompt injection and urgent features exploit. One middleware stack means one place to patch IDOR bugs, one audit format, and one set of integration tests mobile and web already rely on.
How do we test multi-tenant isolation?
Automated tests with two tenants, two users, and deliberate cross-tenant ids in retrieval and tool args. Assert HTTP 403 or empty scoped results, not model apologies. Run after every change to indexes, tool schemas, or JWT claim mapping—not only before launch.

Sources

Related service

APIs, data stores, auth, observability, and cloud infrastructure that hold up under real traffic.

View hire details


Published on September 17, 2026 by Berktug Berke Ates.