
Feeding Agents Your Documents Without Feeding Them Your Secrets
- Documents are what make an agent useful, and also how it leaks. The risk is not the model, it is everything you let flow into the index before a question is ever asked.
- Classify before you ingest. A four-tier label (public, internal, confidential, restricted) decided at the door beats any cleanup attempted after embedding.
- Redact in a way that survives retrieval: mask identifiers consistently so search still works, and treat embeddings as sensitive derived data, not a harmless index.
- Enforce access control before retrieval, using the source system's permissions, and re-check at answer time. IBM found that 97% of organizations that reported an AI model or application breach lacked proper AI access controls.
- Log what the agent can see and what it actually retrieved. If you cannot answer "who saw which chunk and why," you do not have an audit trail.
Every team I talk to wants the same thing from an agent: read our documents and tell us things. Almost none of them ask the follow-up question, which is what else the agent now knows and who can get it to say so. This is a practical guide to giving an agent your documents without giving it your secrets, built around the four decisions that actually matter: what goes in, what gets scrubbed, who can pull it back out, and how you prove it afterward.

Why Useful and Leaky Sit So Close Together
An agent that can read your documents is useful for the same reason it is dangerous: it can retrieve anything you let it index, for anyone who can ask it a question. Usefulness and exposure are one capability pointed at two outcomes.
The numbers back up the worry. IBM's 2025 Cost of a Data Breach report found that 13% of organizations reported a breach of an AI model or application, and 97% of those lacked proper AI access controls. The same research found that 63% of breached organizations had no AI governance policy or were still developing one. Those are survey figures from breached companies, so read them as a pattern rather than a forecast for your shop. The pattern is hard to miss, though: the failures cluster where nobody decided who the AI is allowed to show what.
Part of the exposure comes from your own people. Varonis reported finding 57,000 sensitive files with excessive access in an environment it analyzed ahead of a Microsoft 365 Copilot rollout. That figure measures overshared files, not confirmed leaks, and it comes from a vendor with a product to sell. But it describes something I see constantly: a shared drive full of documents that were technically open to everyone and practically never found. A search-powered agent finds them in about a second.
If you want the plain-English mechanics of retrieval first, start with RAG in Plain English. The short version for this article: the agent does not "know" your documents, it looks them up, and whatever the lookup is allowed to return is the real boundary of your security.

Classify Before You Ingest
Classification comes first because every later control, from redaction to access rules, depends on knowing what a document is. Decide it at the door, once, and carry the label with the document everywhere it goes.
Keep the scheme small enough that people will actually use it. I like four tiers:
- Public. Already on your website or in a press release. Safe to ingest for anyone.
- Internal. Ordinary company knowledge. Safe for employees, not for the outside world.
- Confidential. Contracts, pricing, customer records, financials. Ingest only into a scoped index with named access.
- Restricted. Credentials, health or student records, legal holds, regulated personal data. Default answer is no, and exceptions need a written reason.
Then build a gate rather than a policy. An ingestion pipeline should refuse any document with no label, quarantine anything that scans as containing secrets such as API keys or passwords, and write the classification into the document's metadata so it follows every chunk. If you have ever wondered why metadata is the boring thing that makes agents smart, this is the security version of the argument: a label on the chunk is what lets a later rule say no.
Do not forget that documents are untrusted input, not just sensitive data. NIST's generative AI risk profile describes indirect prompt injection, where malicious instructions are placed in data that an AI system later retrieves. A poisoned PDF in your intake folder can try to give your agent orders. Scan for instruction-like text at ingestion, and make sure the agent treats retrieved text as material to read, never as commands to follow.

Redaction and Masking That Survive Retrieval
Redact the fields that carry identity or risk, and do it before embedding, because once text becomes a vector you cannot cleanly pull a name back out of it. The goal is to keep the document searchable while removing the part that hurts if it leaks.
Blunt deletion is the usual mistake. If you replace every customer name with a black box, the agent loses the ability to tell two customers apart, and your answers get worse in ways nobody can explain. Consistent masking works better. Replace "Maria Alvarez" with a stable token like PERSON_0412 everywhere she appears, and the agent can still reason about "the same customer in three contracts" without ever holding her name. Keep the token-to-name map in a separate, access-controlled store so an authorized human can reverse it when they need to.
Choose the lightest control that fits the use case:
- Remove fields the agent has no business reason to see, such as national IDs and payment card numbers.
- Mask identifiers it needs to correlate but not to read, such as names, emails, and account numbers.
- Generalize values where precision adds risk and little value, such as exact birth dates or street addresses.
- Leave intact content that is genuinely low risk, so you do not wreck retrieval quality for no gain.
Treat the embeddings themselves as sensitive. OWASP's Top 10 for LLM Applications lists both Sensitive Information Disclosure and Vector and Embedding Weaknesses as distinct risks, the second covering generation, storage, retrieval, and access control in RAG systems. In practice that means your vector store gets the same encryption, backup, and retention discipline as the source documents. A derived copy is still a copy.

Access Control the Agent Respects
Access control belongs before retrieval, not after. If the system retrieves a restricted chunk and then asks the model to please not mention it, the secret has already entered the context, and a clever prompt will find it.
The rule is simple to say and fiddly to build: the agent should only ever be able to retrieve what the person asking is allowed to read in the source system. That means a few concrete things:
- Carry the source permissions with each chunk. Import the document's access list or group membership at ingestion, not just its text.
- Filter on identity at query time. The search runs as the asking user, so a similarity match that the user could not open is never returned.
- Re-check at answer time. Permissions change when people leave or switch teams, and an index built last month does not know that.
- Never trust permissions written inside the document. A file claiming to be "public" in its own text is not evidence.
- Keep tenants apart in storage, keys, caches, and logs. Separate indexes beat clever filters when the stakes are high.
Agents add a wrinkle that chatbots do not have: they act. Give each one the least privilege that gets the job done, with read-only access by default and no tools it does not need. If you are scoping what an agent may do, Giving an Agent a Budget walks through the idea. And the uncomfortable corollary applies to your whole company: much of the leakage risk is shadow usage by well-meaning staff, which is why Shadow AI Is Already in Your Company belongs next to this one. IBM's research found that breaches involving shadow AI added about $200,000 on average to breach costs.

Auditing What the Agent Can See
An audit trail answers one question after the fact: who saw which piece of information, through which agent, and why was that allowed. If you cannot answer it, you cannot investigate an incident, and you cannot prove to a customer or regulator that your controls worked.
Log at three points. At ingestion, record the document, its version, who submitted it, the classification assigned, and any redaction applied. At retrieval, record the user, the query, the chunks returned, and the access decision for each. At action time, record every tool call the agent made with what data. Keep the logs somewhere the agent itself cannot edit.
Retention deserves a decision too. Deleting a source document does not delete its OCR text, its chunks, its embeddings, its cached answers, or its backups. Write down the full deletion path and test it, because "we deleted it" is only true when every copy is gone. For a customer who asks you to forget them, that list is your answer.
Finally, rehearse the bad day. Plant a canary document, a fake file with a unique phrase, in a restricted folder and see whether any ordinary user can get the agent to surface it. Run it monthly. When something does go wrong, AI Incident Response covers what to do in the first hour, and good logs are what make that hour survivable.

Frequently Asked Questions
How Do You Securely Give AI Access to Company Documents?
Classify every document at ingestion, scrub or mask sensitive fields, and carry the source permissions with each chunk. Then enforce access at retrieval time based on who is asking, and log every ingestion and retrieval event. Start with a small, low-risk set of documents and widen only as the controls prove themselves.
How Do You Prevent Data Leaks in a RAG System?
Apply authorization filters before similarity results reach the model, not after. Encrypt the vector store, keep tenants separate, and treat embeddings as sensitive derived data. Test regularly with canary documents to confirm restricted content cannot be retrieved by the wrong user.
What Data Should You Redact Before Ingestion?
Remove anything the agent has no business reason to see, such as government IDs, payment card numbers, and credentials. Mask identifiers it needs to correlate, like names and account numbers, with consistent tokens. Leave low-risk content intact so retrieval quality does not suffer.
How Do You Keep AI From Leaking Data?
Limit what it can retrieve, limit what it can do, and log both. Restrict the agent to the asking user's permissions and give it only the tools it needs. Add output checks as a backstop, but never as the main defense.
What Is Data Classification?
Data classification is sorting information into tiers, such as public, internal, confidential, and restricted, based on how much harm its exposure would cause. The label then drives every downstream rule about who can see it and how it is handled. For AI ingestion, it is the first gate a document passes through.
References
- IBM Report: 13% of Organizations Reported Breaches of AI Models or Applications, 97% of Which Reported Lacking Proper AI Access Controls
- IBM Cost of a Data Breach 2025: Executive Summary
- Varonis: Microsoft Copilot Security
- NIST AI 600-1: Generative AI Profile
- OWASP Top 10 for LLM Applications
- RAG in Plain English: How Retrieval Actually Makes an Agent Useful
- Metadata Is the Boring Thing That Makes Agents Smart
- Giving an Agent a Budget: How to Scope What It's Allowed to Do
- Shadow AI Is Already in Your Company. Here's How to Govern It
- AI Incident Response: What to Do When an Agent Gets It Wrong
