# Design a Work Copilot That Never Leaks Data the User Can't Access

> How to build a work copilot that shows each person only what they could already open, explained simply for your AI interview.

**In short:** A work copilot should check the asking user's own access at the moment it searches, and pass only text they may open to the model. Copied permission lists go stale, and shared caches can leak answers, so both need care.

AI and LLM interview question Q352, LLM system design. Advanced, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/design-a-work-copilot-that-respects-permissions

## Say it in 30 seconds

A work copilot answers questions from company files, so it has to show each person only what that person could already open. My design checks the user's own access at search time, before any text reaches the model. I don't trust a copy of permissions made last month. I also key caches, logs and tools to the user. Then I test as users from every group, and as an attacker.

## Say it in 2 minutes

A work copilot reads company files and answers questions about them. The danger is simple. If it searches everything and only then decides what to show, one clever question can pull out a board memo meant for three people. So the permission check comes first, before ranking, before the model, and before anything reaches the screen.

I'd ask the source system the question, using the user's own sign-in. The source system already knows who can open what, so I'd check that at question time where the source supports it, and keep only what passes. I'd avoid copying access lists into my own index as the main check. A copy goes stale the day someone moves to another team. If I must keep a copy, I'd recheck it before the answer is built.

The wider paths matter too. A shared answer cache is a common leak. If the key is the question alone, the second person gets the first person's answer. So every cache key includes the user's groups. Logs follow the same rule, and each tool call runs with the user's own token, not a service account that can see everything.

Finally, I test it like an attacker. I ask the same questions as users from each group, then check that nothing hidden shows up in the answer or in its citations. I rerun those tests on every release.

## What is a work copilot that respects permissions, in plain words?

A work copilot is an AI assistant that answers questions from a company's files, mail and chats. It finds the right passages and writes a clear answer. It is good at finding things, and that is the risk: it can find a file the person asking was never meant to open.

Permissions are the rules that say who may open each file. A copilot respects them when every answer uses only what the person could already open by hand. The model has no idea who is asking, so the check has to live in code around it.

Think of a bank teller who checks your ID before opening the safe deposit box you rented. The teller checks at the counter, every time, and doesn't rely on a list written last month. A copilot needs the same counter.

A sample question might be "What is the walk-away price?", typed by an analyst on a deal team. The copilot should answer only if that analyst may open the file that holds the number.

- **Permission filter:** The check that removes files the user cannot open, before any text is read.
- **Access control list (ACL):** The list of users and groups allowed to open one file.
- **Query time:** The moment a question is asked, as opposed to when the files were first loaded.
- **Citation:** The source link shown under an answer, so a person can check it.

## How does the copilot see only what you can see?

The copilot does four things, in this order. The order matters: the filter runs before ranking, and before the model reads a single word.

*Diagram, How a permission check travels: The filter drops every file the person may not open, before the model reads a word. The answer then cites only the files that remain.*
1. Her question carries her own sign-in.
2. Every candidate file goes to the filter first.
3. Only the passages she may open reach the model.
4. The answer cites only files she can open.

1. **Use the user's own sign-in:** The question carries the person's identity, not a shared service account with rights to everything.
2. **Ask the source who can open what:** The search checks the file store's permissions right now, for this person.
3. **Drop the rest before ranking:** Passages the person cannot open are removed first, so the model never reads them.
4. **Cite only what is kept:** Every link under the answer points to a file the person could open alone.

Microsoft says Copilot only surfaces data each user has at least view permission for. It also says the tenant's permissions model can help ensure that data won't unintentionally leak between users, groups and tenants.

> "Microsoft Copilot only surfaces organizational data to which individual users have at least view permissions." (Microsoft, Copilot data and privacy)
>
> "A permission-aware vector database should be implemented to restrict access and ensure that only authorized groups can access their specific information." (OWASP, LLM08:2025)

Here is the idea in a small Python program. The made-up deal room has three files. Its permission table is typed in by hand, which is the risky shortcut from the next section. In a real build, that table is replaced by a live check at the source. The HR file is all an HR user gets.

```python
# A made-up deal-room copilot: the permission filter runs before the model sees any text.
DOCS = [
    ("memo-merger-terms", "Target price 41 per share, walk-away at 44", {"deal-team"}),
    ("board-minutes-q3", "Board discussed restructuring the EU unit", {"board"}),
    ("hr-policy-2026", "Remote work allows three office days a week", {"everyone"}),
]

def visible_to(groups):
    return [d for d in DOCS if "everyone" in d[2] or d[2] & groups]

def build_prompt(question, groups):
    lines = ["Context:"]
    lines += ["[" + doc_id + "] " + text for doc_id, text, _ in visible_to(groups)]
    lines.append("Question: " + question)
    return "\n".join(lines)

print(build_prompt("What is the walk-away price?", {"deal-team"}))
print("---")
print(build_prompt("What is the walk-away price?", {"hr"}))
```

Output:

```text
Context:
[memo-merger-terms] Target price 41 per share, walk-away at 44
[hr-policy-2026] Remote work allows three office days a week
Question: What is the walk-away price?
---
Context:
[hr-policy-2026] Remote work allows three office days a week
Question: What is the walk-away price?
```

The filter is simple. Keeping its access data correct is the hard part, and that is the next section.

## Why are copied access lists risky?

A quick build often copies each file's access list into the search index, then filters on that copy. It is fast. But the copy is a snapshot from the day the file was indexed. Someone moved off the deal team on Monday can still get the memo on Thursday if nobody refreshes the copy.

*Diagram, Copied access rules or a live check?: A copied access rule is fast but can go stale. A live check at the source asks on each question, so it does more work per question, and it matches what the person can open today.*
1. Its copy can be out of date once access changes.
2. The source is asked again, so today's access decides.

- **Index-time copy: Fast, but out of date.** A removed user keeps seeing files until the copy is refreshed.
- **Live check at the source: More work, but current.** The source answers for today's access, so a removal should show at the next question.

Microsoft's Foundry IQ documentation lists five main approaches to enforce document-level permissions. Its SharePoint and ADLS Gen2 options copy permission metadata into the index and check it at query time. Its OneLake source option (preview) skips that copy. The security filter pattern trusts the identity the app passes in, and the docs note there's no authentication or authorization through that security principal. They also say a permission-related field name proves nothing by itself.

> **Tip:** Asked how you would build the filter, name the source's own native option and the security filter pattern. Say when each fits. When you must copy access rules, say how often they refresh and who checks them.

## What else can leak: caches, tools and logs?

Retrieval is only one door. A copilot can also leak through a cache, a tool, a log or a saved memory. Each one needs the same rule: the user's access, checked at the moment it is used.

1. **Answer cache:** Key each saved answer by the question and the user's groups, so answers never cross people.
2. **Tools:** Run each action with the user's own token, so a send or a file write cannot reach what that person could not open.
3. **Logs and traces:** Store questions and answers under the same access rules as the source documents.
4. **Memory:** Keep anything the copilot remembers scoped to one person or one team, never the whole company.

Here is the cache failure in a worked case. Priya on the deal team asks the walk-away question at 10:05. Sam in HR asks the same words at 10:20, and a shared cache hands him her answer.

- **Shared cache key: Sam gets the memo.** The key is the question text only, so Sam's question hits Priya's cached answer.
- **Scoped cache key: Sam's question is checked.** The key includes the groups, so Sam misses the cache and the search checks his access.

OWASP's 2025 list ranks sensitive information disclosure as LLM02. Its advice is least privilege: limit access to sensitive data to what each user or process needs. Exposure can mean unauthorized access, privacy violations and lost intellectual property.

Test it like an attacker would. Ask the same questions as a user from each group, then search every answer and citation for text from files that user cannot open. Rerun those tests on every release, and add any leak you find to the test set.

### How would you handle access removed mid-day?

A deal-team analyst moves to another project at 9:00. At 9:30 she asks a question that the old deal room used to answer. What should happen, and what would you check?

1. **The source decides:** Her access is checked against the file store at 9:30, so the removed files drop out of search.
2. **The cache follows:** Answers cached under her old groups no longer match her key. In my design, cached answers also expire on a short timer and are dropped when a file's permissions change. A short timer still leaves a small window, and I'd say so.
3. **The log tells the story:** Earlier answers stay in the audit trail, so the team can review what she saw and when.

> **Tip:** Say how fast removal works. A live check at the source removes access at the next question. A copied index waits for its next refresh, and Microsoft's docs say a refresh gives no immediate revocation. That gap is the honest answer to give.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: the copilot shows only what the person could already open.
- [ ] Where the check runs: at question time, before the model reads any text.
- [ ] Why copied access lists go stale, and the query-time alternative.
- [ ] Caches, tools, logs and memory each need the same rule.
- [ ] Testing as users from each group, plus an attacker's view.
- [ ] Honest limits: the permissions in the source system must stay correct.

**Common traps**

- Trap: "Filter the answer after the model writes it." Better: Too late. The model has already read the hidden text and can repeat it in a summary. Filter before the model reads.
- Trap: "Copy each file's permissions into the index, and we're done." Better: A copy goes stale. Check access at question time, or refresh and recheck the copy before answering.
- Trap: "One service account can read everything, so the app checks users." Better: Then the app's own code is the only lock. Let the source check the user's own sign-in too.

## Can you spot the leak?

**Spot the leak:** A copilot caches its answers. Which cache design leaks one user's answer to another?

A. Keys include the question and the user's groups.
B. Answers are logged under the same access rules as the files.
C. Keys use the question text only, so Priya's answer can be served to Sam.
D. Tools run with the asking user's own token.

**Answer:** C. A key without the user's groups hands one person's answer to anyone who asks the same words. The other three each keep an answer tied to the person who may see it.

**Quick check:** Which change stops a removed user from seeing a file in an answer?

A. A longer system prompt that forbids sharing secret files
B. A check against the source's access at question time, before the model reads the file
C. A bigger model that follows the rules more carefully
D. A lower temperature so the model is more careful

**Answer:** B. The check must run in code before the text reaches the model. Prompts, model size and temperature cannot remove text the model has already read.

## Can you answer these from memory?

**Flash cards**

- **What must a work copilot check?** Who is asking and what that person may open, at question time.
- **Why not copy permissions into the index?** A copy goes stale, so a removed user can still see files.
- **Where should the filter run?** Before ranking, and before the model reads any text.
- **What must a cache key include?** The question plus the user's groups, so answers never cross people.
- **Which identity should a tool use?** The user's own sign-in and token, not a shared service account.
- **How do you test it?** Ask as users from each group and check nothing hidden shows up.

## Likely follow-up questions

- Q201 What is prompt injection? https://designervenkat.online/interview/ai/what-is-prompt-injection
- Q348 Design company document Q&A. https://designervenkat.online/interview/ai/design-company-document-qa
- Q353 Design an LLM gateway. https://designervenkat.online/interview/ai/design-an-llm-gateway
- Q354 What are the multi-tenant concerns? https://designervenkat.online/interview/ai/what-are-the-multi-tenant-concerns
- Q209 How do you build defence in depth against injection? https://designervenkat.online/interview/ai/defence-in-depth-against-prompt-injection

## Learn it in depth

- [Unauthorized access](https://designervenkat.online/learn/ai-guardrails/unauthorized-access)
