Skip to content

    AI Architect Case Files

    Case: Helpdesk Assistant Design Review, Trust Boundary

    A design review of a B2B SaaS support assistant found tenant data crossing into a shared tool server with no boundary, and what the redrawn design changed.

    By Published 8 min read

    • ai-architect
    • case-file
    • industry-saas-b2b
    • pattern-trust-boundaries
    • failure-data-leak
    • kind-composite
    Share

    Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.

    This case belongs to Diagramming AI systems.

    Context

    • A software vendor sells a multi-tenant B2B product. Each customer organisation is a tenant; its administrators contact support about configuration, billing and open tickets.
    • A support assistant inside the product answers in plain language and looks up that tenant's tickets and settings through a few tools.
    • One shared Document store holds the data, with a tenant identifier on every record. One shared Tool server exposes the lookup tools.
    • The design comes to review as a container diagram only: no sequence diagrams, no trust boundaries.

    Problem statement

    The review asks: where does the tenant identity come from at each step, and who checks it? The container diagram cannot answer, so the reviewers ask for the runtime sequence of one tool call. Drawing it takes ten minutes and shows the problem.

    Figure 1. Runtime sequence as first designed (flawed)

    sequenceDiagram accTitle: Original tool call sequence with the tenant id chosen by the model accDescr: The API gateway passes a question to the Orchestrator. The model, reached through the Model gateway, replies with a tool request that includes a tenant id. The Orchestrator forwards that tenant id to the shared Tool server, which holds one credential that can read every tenant and queries the Document store with it. autonumber participant G as API gateway participant O as Orchestrator participant M as Model gateway participant L as LLM provider participant T as Tool server participant D as Document store G->>O: question plus session O->>M: prompt with question and account context M->>L: model request L-->>M: tool request get_ticket_history(tenant_id=t-17, ticket_ref) M-->>O: tool request get_ticket_history(tenant_id=t-17, ticket_ref) Note over O: The tenant id comes from the model output O->>T: get_ticket_history(t-17, ticket_ref) Note over T: One service credential can read every tenant T->>D: read ticket_ref where tenant = t-17 D-->>T: record T-->>O: record

    How to read this: time runs downward, and the two notes mark where tenant identity is decided and where it is not checked.

    The tenant identifier is an argument the model writes, and anything in its context can influence it: the administrator's message, an earlier ticket, a pasted log. The Tool server trusts the argument and can read every tenant. The missing item is a trust boundary between the Orchestrator and the Tool server, with a control on it.

    Goal: a tool call reads only the logged-in tenant's data, whatever the model writes, and the review can point to the control that guarantees it.

    Constraints

    • One shared Tool server and one shared Document store; separate stacks per tenant are out of budget.
    • Answers stay interactive, so any added control has a small latency budget.
    • Administrators may paste arbitrary text, including logs and emails.
    • Audit: every tool call is attributable to a tenant and a user.
    • The model provider receives no credentials.

    Why the traditional approach fell short

    Approach Where it fell short
    Help centre search plus a ticket form Public articles cannot answer "why was my invoice higher this month?": the answer is in the tenant's own data
    Rules engine mapping fixed questions to fixed lookups Administrators phrase questions in open-ended ways and the rule set never ends
    Manual handling Correct and slow

    Options considered

    Option Idea Why accepted or rejected
    A. Validate in the Orchestrator Keep the design, add a check that the tenant id in the tool request equals the session's tenant Rejected as the only control: one check in one place, the Tool server can still read every tenant, and a new tool may skip it
    B. Tenant-scoped credential, enforced below the model The tool schema has no tenant parameter. The gateway sets the tenant; the Policy engine returns a short-lived credential scoped to it. The Tool server and Document store enforce it Accepted: the model cannot widen access, and two layers must both fail for a leak
    C. No tenant-data tools (non-AI) The assistant answers only from public documentation and offers a ticket form Kept as the fallback for tenants that decline tool access, and the simplest option for rare lookups

    The default is B: authority must never live in a value the model writes. Option C is not a failure; for a small feature set it is cheaper and safer.

    Solution architecture

    Figure 2. Container view with trust boundaries

    Container view of the redesigned assistant with trust boundariesClient app to API gateway (B1: session token); API gateway to Orchestrator (B2: tenant, user (gateway)); Orchestrator to Policy engine (may user call tool?); Policy engine to Orchestrator (credential or deny); Orchestrator to Model gateway (prompt); Model gateway to LLM provider (B5: prompt, no credentials); Orchestrator to Event bus (audit event); Orchestrator to Tool server (B3: one-tenant credential); Tool server to Document store (B4: tenant filter)A: TENANT-FACINGB: PER-REQUEST APPLICATIONC: TOOLSD: DATAClient appClient appAPI gatewayAPI gatewayPolicy enginePolicy engineOrchestratorOrchestratorModel gatewayModel gatewayEvent busEvent busTool server: sharedTool serversharedDocument storeDocument storeLLM provider: externalLLM providerexternalB1: session tokenB2: tenant, user (gateway)may user call tool?credential or denypromptB5: prompt, no credentialsaudit eventB3: one-tenant credentialB4: tenant filter

    How to read this: zones are shaded boxes, arrows whose label starts B1 to B5 cross a trust boundary and name the control applied there, the other solid arrows stay inside a zone, and the dashed arrow is asynchronous.

    Figure 3. Runtime sequence of the corrected tool call

    sequenceDiagram accTitle: Corrected tool call sequence with a scoped credential accDescr: The API gateway sets the tenant and user. The model, reached through the Model gateway, asks for a tool without a tenant argument. The Orchestrator asks the Policy engine, which either allows the call and returns a credential scoped to the tenant, or denies it and no call is made. With the credential the Tool server reads the Document store restricted to that tenant. The Orchestrator publishes an audit event. autonumber participant G as API gateway participant O as Orchestrator participant M as Model gateway participant L as LLM provider participant P as Policy engine participant T as Tool server participant D as Document store participant E as Event bus G->>O: question plus tenant and user set by the gateway O->>M: prompt, no tenant field in any tool schema M->>L: model request L-->>M: tool request get_ticket_history(ticket_ref) M-->>O: tool request get_ticket_history(ticket_ref) O->>P: may this user of this tenant call get_ticket_history? alt allowed P-->>O: allow plus 60 s credential scoped to the tenant and the tool O->>T: get_ticket_history(ticket_ref) with credential Note over T: Validates the credential before any read T->>D: read ticket_ref where tenant = tenant in credential D-->>T: record, or empty if it belongs to another tenant T-->>O: result Note over O: The result goes back to the model for the final answer, as in the normal flow else denied P-->>O: deny Note over O: No tool call is made and the user is told end O-)E: audit event with tenant, tool and outcome

    How to read this: the alt block has an allowed path and a denied path, and in both the Orchestrator ends by publishing an audit event.

    How AI solved it, step by step

    Step through one request, then compare "Without the fix".

    One tool call, corrected and as first designed (interactive when JavaScript is on)

    As designed

    1. Ask. The administrator of tenant T asks, "Why is ticket 4821 still open?" The Client app sends it with a session token.
    2. Gateway sets identity. The API gateway verifies the session and attaches tenant and user as request fields, never as instructions in prompt text.
    3. Prompt. The Orchestrator builds the prompt. No tool takes a tenant argument.
    4. Model replies. The LLM provider replies, through the Model gateway, with a request for the ticket-history tool and the ticket reference.
    5. Policy check. The Orchestrator treats the reply as a request, not a command, and asks the Policy engine whether this user may call this tool.
    6. Credential or deny. If yes, a 60-second credential scoped to tenant T and that tool comes back. If no, no call is made and the user is told.
    7. Tool server enforces. The Tool server validates the credential, then queries with a tenant filter taken from it.
    8. Result and audit. The store returns the record, or nothing if it belongs to another tenant. The model writes the final answer and the Orchestrator publishes an audit event.

    Without the fix

    1. Ask. The API gateway passes the administrator's question to the Orchestrator with the session.
    2. Model writes the tenant. The model replies with get_ticket_history(tenant_id=t-17, ticket_ref). The tenant id is an argument the model wrote.
    3. Forwarded unchecked. The Orchestrator forwards the tenant id to the Tool server as given.
    4. Read with a broad credential. The Tool server holds one credential that can read every tenant and reads whatever the argument names. Nothing checks it against the logged-in tenant.

    Every decision in the corrected path is made by code the model cannot influence: the gateway (who), the Policy engine (may they), the Tool server and store (enforce).

    Under the hood

    A model's output is shaped by every token in its context, including text the team did not write: the user's message, retrieved documents, tool results. A tool argument is part of that output. So any value that grants authority (tenant id, user id, file path root) is attacker-influenced if the model can set it.

    Layer Control
    Schema Remove the parameter: no tool takes a tenant argument
    Identity Supply the value from a verified channel: the gateway sets tenant and user
    Enforcement Enforce it again where the data is read: the Tool server and the Document store

    The trust-boundary section of Diagramming AI systems shows how to mark these crossings; the course's security lesson will cover the attack chains.

    What went wrong / failure modes

    Failure Mitigation
    A new tool is added later with a tenant parameter Tool schema review is on the design checklist, and the Tool server rejects calls without a credential whatever the arguments say
    A cache is keyed by ticket reference only, so one tenant's record could be served to another Every cache key includes the tenant; the review asks of each store, "what is its key?"
    The credential is longer-lived than the request A short lifetime and a scope of one tenant and one tool
    Audit gaps if the Event bus is down The Orchestrator buffers events locally and retries; a tool call whose audit event cannot be buffered is refused
    Policy engine unavailable Fail closed and tell the user the lookup is unavailable

    Results

    These are illustrative targets, not measurements.

    Measure Target
    Cross-tenant reads in a pre-release adversarial set of 300 prompts (pasted text naming another tenant, requests to "ignore the account", ticket text containing an instruction) Zero
    Added latency from the Policy engine call 30 ms at the median
    Audit coverage 100% of tool calls produce an audit event carrying tenant, user and tool
    What-if sizing: a 0.1% wrong-tenant error rate 10 wrong-tenant reads a day across 10,000 daily tool calls (25,000 requests x 40%)

    Qualitative outcome: the missing boundary was found before any tenant data was exposed, because a sequence diagram was drawn.

    Tradeoffs and when NOT to use this approach

    • Option B adds a Policy engine call and credential handling to every tool call. For a read-only assistant over public data it is not worth it.
    • A shared Tool server remains a concentration of access. Contractual isolation requirements may need separate stacks, and no in-process check replaces that.
    • This is not a fix for prompt injection. It limits what an injected instruction can reach; it does not stop the model from being steered.

    Design rules extracted

    1. Authority never lives in a value the model writes: tenant, user and permission come from a verified channel.
    2. Draw the runtime sequence of one tool call before approving a design; the container diagram alone hides where identity is decided.
    3. Enforce at two layers, the tool tier and the data tier, so that one missed check is not a leak.
    4. Keys of caches, indexes and logs include the tenant.
    5. When the policy check or the audit path is down, fail closed.

    Assumptions

    • 400 tenants, 25,000 assistant requests per day, and 40% of requests call a tool, which gives 25,000 x 0.40 = 10,000 tool calls per day.
    • A what-if used in the review: an error rate of 0.1% on 10,000 daily tool calls would be 10 wrong-tenant reads per day. The 0.1% is a what-if, not an observed rate.
    • The adversarial test set of 300 prompts, the 60-second credential lifetime and the 30 ms latency target are chosen for illustration.
    • The vendor, product and tenant ids (such as t-17) are invented.

    Last verified: 2026-10-21

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments