Security, Governance and PlatformTenant and data boundariesPrincipal
How should a tool enforce tenant scope when retrieved content mentions another customer’s ID?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A support agent acts for customer A. An authorized note mentions customer B’s account ID, and the agent calls get_account with tenant_id=B using a broad service credential. Explain why valid retrieval and schema checks are insufficient, place the server-side authorization boundary, and design a legitimate cross-account workflow plus exposure investigation.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The agent was allowed to choose an account to investigate, but that is not the same as choosing its authorization scope. A tenant ID found in retrieved text is task data, not a grant. If the tool trusts that argument and runs under a broad service credential, a model mistake or malicious document can become a cross-tenant read. OWASP's broken object-level authorization guidance calls for checking the caller's access to each requested record. The check must apply at the server-side tool boundary, independently of whether the LLM asked politely or whether search should have returned the note.
I would trace the authenticated principal, customer context selected by the real user, delegated scope presented to the tool, returned search document and exact tool parameters. The server derives or validates tenant scope from an authenticated session or delegated capability, not from an untrusted model-supplied tenant field. For a cross-account support workflow, require an explicit approved role and reason, a scoped token, audit, and a UI that makes the account switch visible. A generic database credential with unrestricted tenant access makes one missed check catastrophic.
Defense in depth matters. Filter retrieval by authorized tenant, label snippets with provenance, and reject mismatched tenant IDs in the tool. Test crafted notes that contain plausible IDs for other customers, including indirect references and tool-call-looking text. Log the attempted cross-tenant call without copying B's private response into the agent's context. If the tool did return it, investigate downstream use, caches, traces and retention. The answer must account for exposure, not just fix the next request.
An interviewer may say the search index was already permission filtered. Good, but a document belonging to A can legitimately mention B. That mention still cannot authorize reading B's account. A new tool field can bypass the old authorization check covers a newly added tool field that bypasses an old check, and The SQL tool uses parameters. Why can the agent still choose the wrong table? covers agent-selected SQL tables. This question is narrower: a valid object identifier learned from content must be bound to the acting principal at execution time.
A scoped lookup can combine object selection with the trusted tenant predicate. Conceptually, load an account only where its ID matches the request and its tenant matches the independently authenticated scope. Then apply any additional record-level permissions. Looking up by account ID first and filtering only after serializing the result creates an unnecessary exposure path through logs, traces or caches. Returning an unauthorized object to the model and instructing it not to disclose it is already too late.
A composite tenant/account key also avoids ambiguity if account IDs are unique only within a tenant. A globally unique ID makes object lookup convenient, but does not grant access. Support personnel who may switch accounts need a separately authorized switch or role with a visible purpose, rather than permission to let any retrieved tenant string redefine the session.
Use a fixture in which A’s own document legitimately contains B’s ID. Retrieval filtering should allow the document, while the account tool must deny the unauthorized read. That isolates the authority boundary from retrieval quality. A second fixture grants a support role the specific cross-account permission and checks that the resulting audit identifies the scope change. If B’s data was already returned, trace derived summaries and cache entries as part of containment instead of treating a future denial as retroactive repair.
Related questions
Keep practising security, governance and platform
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux