DEV Community

Cover image for AI Agent Security for Teams: How to Make the AI See Only What Each Person Can
Justin
Justin

Posted on

AI Agent Security for Teams: How to Make the AI See Only What Each Person Can

TL;DR:

An AI agent that can read company files will read whatever its tools allow, regardless of what its instructions say. When a whole team shares one AI, file permissions become the most important part of AI agent security. The OWASP Top 10 for LLM Applications lists excessive agency and sensitive information disclosure among the top risks for exactly this reason. This guide explains how agents reach files, the common ways teams try to limit them, where each one leaks, and how to enforce per-person access on every file the AI opens.

Giving an AI assistant access to company documents is the step that makes it useful. A model that can read the price list, last quarter's reports and the client folder gives far better answers than one working from a blank page. It is also the step that makes security teams nervous, and for good reason. The moment an AI can read files, the question of which files becomes as important as how good its answers are.

For one person using their own assistant, the answer is simple: the AI sees what that person sees. For a team sharing one AI setup, it gets complicated fast, because the people asking questions do not all have the same access. This piece follows one fictional firm through that problem. By the end, you will know how AI agents reach files, why instructions and shared accounts fail as access controls, what per-person enforcement looks like in practice, and how to test that it holds.

The Basics of How AI Agents Read Files

An AI agent is a model that can take actions as well as write text. It reads a request, decides it needs information, calls a tool to get it, reads the result and repeats until it has an answer. Claude Code and Codex are agents in this sense: a single answer can involve dozens of tool calls.

File access happens through those tools. The common ones are:

  • File tools, such as "read this file", "list this folder" or "search these documents".
  • A shell, which lets the agent run commands like cat, grep or a script, and so read anything the shell's account can read.
  • Connectors, such as an MCP server for Google Drive or a company API, which fetch documents from other systems.
  • Retrieval, where a search index returns chunks of documents relevant to the question.

The important idea is that the model itself has no sense of permission. It reads whatever a tool returns. If a tool can open a file, the model can see it, whatever the system prompt says. Permission has to live in the tools and the systems behind them.

Our running example is Halden & Co., a fictional 40-person accounting and advisory firm. Partners can see everything. Client managers see their own clients' folders. HR files are restricted to two people. The firm wants one shared AI that every employee can ask, without any of them seeing files they could not open themselves.

Why AI Agents Make File Permissions Harder for Teams

Halden's existing file server already has folder permissions, and people rarely think about them. An AI agent changes that in three ways.

First, an agent reads far more than a person does. A person opens the three files they need. An agent asked "summarise our exposure to client X" might search hundreds of documents and pull in anything that matches. Folders that nobody ever browsed by hand suddenly get read.

Second, the agent's answers travel. A person who reads a sensitive file keeps it in their head. An agent that reads one writes parts of it into an answer, and that answer can be copied, shared in a team chat or continued by a colleague. Data that was protected at the file level is now sitting in a chat.

Third, agents can be manipulated through their inputs. The OWASP Top 10 for LLM Applications 2025 lists prompt injection as its first risk: user inputs, including text hidden inside documents or web pages, can change what a model does. An agent that reads an attacker's document might be told to fetch another file or send what it found somewhere else.

OWASP groups the consequences under excessive agency, which it defines as giving an LLM system more autonomy or permissions than it needs. Its root causes are excessive functionality, excessive permissions and excessive autonomy, and all three show up when a team plugs an agent into a shared drive.

Four Approaches to AI Agent Access Control and Where Each One Leaks

Teams usually reach for one of four approaches when they first connect an AI to company files. Each is worth understanding, because each fails in a specific, predictable way.

The first is one shared service account. The AI connects to the file server or Google Drive as a single account with broad access, so it can answer anyone's question. This is the most common setup and the weakest. Every user effectively inherits the service account's access. At Halden, a junior associate could ask about HR files and the AI would happily read them.

The second is instructions in the prompt. The system prompt says something like "only use files from the user's department" or "never read the HR folder". The problem is that nothing enforces it. The model can misread the rule, a cleverly worded question can talk it out of the rule, and an injected instruction in a document can override it. Claude Code's own memory documentation draws this line clearly: CLAUDE.md instructions are guidance, while permission settings are what the client enforces.

The third is filtering at retrieval time. The search index stores permissions alongside each document chunk and only returns chunks the user may see. This is a real improvement for search-based assistants. It leaks when the agent has other ways to reach files, such as a shell or a second connector, and when the filtered index falls out of sync with permission changes.

The fourth is checking every tool call as the person who asked. Each time the agent tries to read, list or search a file, the system checks the requesting person's access before returning anything. This is what OWASP recommends: actions should run "in the context of that specific user", with authorisation enforced "in downstream systems rather than relying on an LLM to decide". It is also the hardest to build, because it requires that every path to a file goes through that check.

Trina

What Per-Person Enforcement Needs in Practice

Checking every tool call sounds straightforward until you list the ways an agent can reach a file. Making it hold takes four things working together.

  1. No unchecked paths to files. If the agent has a shell running as an account that can read the whole drive, the file-tool check is decorative. The shell has to be removed or confined so it cannot reach files outside the check.
  2. Isolation at the operating system level. Even with the shell off, the agent process should run as its own account with a sandbox around it, so a bug or an exploit cannot reach the file system directly.
  3. A decision before reading, not after. Once the agent has read a file, the contents are in its context and may appear in an answer. The check has to happen before the file is opened.
  4. Care when work is shared. If one person's answer quoted a restricted file, sharing that chat with a colleague shares the quote. The system needs to warn, or ask, before that happens.

OWASP adds a fifth practice that sits alongside these: require human approval for high-impact actions, such as posting content or deleting files. For a team AI, that applies to anything that writes to another system, like creating an invoice in accounting software.

At Halden, this list turns into concrete tests. Can a client manager's AI see another manager's client folder? Can anyone except the two HR staff get HR content into an answer by any route? If a partner shares a chat that used HR files, what happens? The next section looks at how one open-source team server answers those questions.

How Trina AX Enforces Folder Permissions on Every AI File Read

Trina AX is an open-source (AGPL-3.0) team server that runs the real Claude Code and Codex for everyone in a company. Its central design choice is the fourth approach above: the AI's access to company files is checked against the person who asked, on every call. Here is how it lines up with the requirements from the previous section.

No unchecked paths to files. Claude Code's and Codex's own shell and file tools are turned off. The only way the engine reaches a company file is through Trina's file tools, and every one of those calls passes one permission check on the server. Folders a person cannot open do not appear to their AI at all. When the AI needs to run code, it does so through a separate tool that runs each command in its own sandbox and rechecks the person's write access to the project folder each time. New teams on Linux servers get that sandbox on by default.

Isolation at the operating system level. On a Linux server, the engine runs as its own operating system account inside bubblewrap, Landlock and seccomp. If the engine misbehaves, the sandbox limits what it can touch beyond Trina's tools.

A decision before reading. Folder access in Trina is set per folder, with Viewer and Editor roles and a "Limit access" option. Because the check runs on each file request, a client manager at Halden asking about a colleague's client gets nothing from that folder, and HR files never enter the AI's context for anyone outside HR.

Trina

Care when work is shared. Trina handles the sharing problem at several points. Before the AI sends an answer to a team room, it asks first if the answer used files some members of that room cannot open. When someone shares a chat or adds a person to it, Trina shows a warning such as "3 answers used files Priya can't open". When a teammate picks up a shared session, the raw tool results from earlier turns do not come along: the new person's AI starts from the visible conversation, and new answers run with their own access. Admins cannot open team rooms they are not in, and a person's chats with Trina are visible only to them unless they are in a shared team project.

Prompt injection and outbound links. Trina does not claim to solve prompt injection, and nobody can yet. By default the AI asks before opening a web address it wrote itself, which closes the most direct way an injected instruction could send data out. If an admin turns on "Allow all websites", a hidden instruction in a file could make the AI send what it can read to a site, and the security documentation says so plainly. Links that come from search results or pages the AI has read open without asking, up to 30 per answer and 150 per chat.

Limits worth knowing. Removing someone's folder access does not erase answers they already received. Whoever runs the server, including Trina for hosted teams, can read stored files and chats. Activity records show which files the AI read, without the conversation itself. There is no security certification. The full model is in the security and permissions documentation, and the repository includes role-by-role permission tests.

AI Agent Security Best Practices: Testing Permissions Before Rollout

Whatever tool you use, test permissions the way an employee might break them. A short test plan catches most problems.

  1. Ask across a boundary. Sign in as someone without access to a folder and ask a question only that folder can answer. The AI should not be able to answer from it.
  2. Ask indirectly. Ask for a summary of "everything we know about" a restricted topic without naming the file. Indirect questions find gaps in retrieval filters.
  3. Try to talk past it. Ask the AI to ignore its instructions, or claim you have permission. A real control does not care how persuasive the question is.
  4. Plant an instruction. Put a document in a folder you can read with a hidden line telling the AI to fetch a restricted file or visit a URL. Watch what happens.
  5. Share and hand over. Have someone with access use a restricted file in a chat, then share that chat with someone without access. Check what the second person sees and what warnings appear.
  6. Remove access mid-way. Remove a person's folder access and check that new answers no longer use it, while remembering that old answers remain.

At Halden, the planted-instruction test is the one that changes minds. It shows the difference between an AI that has been asked to behave and one that physically cannot reach the file.

Where Should You Start With AI File Permissions

AI agents read through tools, so permission has to live in the tools and the systems behind them. Shared service accounts give everyone the same broad access, prompt instructions can be ignored or overridden, and retrieval filters leak when an agent has another path to files. The approach that holds is checking every tool call as the person who asked, with no unchecked shell and a sandbox around the engine.

If your team is connecting an AI to company files, start by mapping every path the agent has to your data, then run the six tests above as a person with limited access. To see per-person enforcement in a working product, try the Trina AX browser demo with its fictional team, or read the security and permissions documentation and run the tests against a self-hosted install.

FAQ

Can a system prompt stop an AI agent from reading certain files?

No. A system prompt is guidance the model can misread, be talked out of, or have overridden by injected text. Real control comes from tools that refuse to return files the person cannot open.

What is excessive agency in AI applications?

It is OWASP's name for giving an LLM system more functionality, permissions or autonomy than it needs. The risk is that unexpected, ambiguous or manipulated outputs lead to damaging actions. OWASP recommends running actions in the user's context with the minimum privileges needed.

Is filtering search results by permission enough for an AI assistant?

It helps for search-only assistants. It is not enough if the agent can also reach files through a shell or another connector, or if the filtered index lags behind permission changes.

Does Trina AX let the AI run code or shell commands?

Yes, through a separate tool rather than Claude Code's own shell. Each command runs in its own sandbox, and the server rechecks the person's write access to the project folder every time.

If a colleague continues my Trina AX session, can they see files I used?

They can see whatever is already in the visible answers, which is why Trina warns before sharing when earlier answers used files someone cannot open. The raw tool results do not carry over, and their new answers run with their own access.

Does Trina AX prevent prompt injection?

No product fully prevents it today. Trina reduces the main exfiltration route by asking before the AI opens a web address it wrote itself, and its documentation explains what changes if an admin turns on "Allow all websites".

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

The Halden & Co. example made the risk concrete for me — a person opens the three files they need, while an agent reads far more and its answers travel, so a shared service account quietly turns one person's access into everyone's. Your six-test plan is the part I'd steal first, especially the planted-instruction test, since it shows whether the control is real or just a system prompt the model can be talked out of. When someone's folder access is removed mid-project, does Trina AX also warn about answers they already received that quoted restricted files, or is that warning only raised when a chat is shared?

Collapse
 
emma_parker_0c05a1541146a profile image
Emma Parker •

The distinction between instructing an AI agent to respect permissions and actually enforcing those permissions at the tool level is critical. One additional challenge is permission changes during an active session. If a user's access is revoked, cached retrieval results, conversation memory, and previously generated summaries can still contain restricted information.

When designing enterprise AI systems at IT Path Solutions, I'd treat authorization as a continuous enforcement layer rather than a one-time authentication check. Every retrieval, tool call, and data-sharing action should validate the user's current permissions, with audit logs tracking what the agent accessed and why.

A secure AI agent shouldn't simply know what it is allowed to access; the underlying architecture must make unauthorized access technically impossible, even when prompts are manipulated or workflows are shared.