Agentshield

Secure RAG Pipeline - Stop Injection From Your Documents

Your RAG pipeline retrieves untrusted documents and feeds them to the model. That is an injection vector. Secure it by inspecting retrieved content before the agent acts on it.

OWASP LLM Top 10 Immutable audit trail Never trains on your data

Direct answer

A secure RAG pipeline is a retrieval-augmented generation system hardened against indirect prompt injection and data leakage. Because RAG feeds retrieved documents into the model, a poisoned document can carry hidden instructions that hijack the agent. Agentshield inspects retrieved content for injection before it influences an action, enforces what the RAG agent may then do, and blocks sensitive data from leaving to unauthorized destinations, so the pipeline cannot be turned against you by its own sources.

Try it live

Watch Agentshield block an attack in real time.

Pick a scenario and drive the inspection lane yourself. No signup needed.

Threat Console
Interactive demo · 0 blocked in this session

Run a request

Runs the live engine on your text. Nothing is stored, no account needed.

Inspection lane

INSPECTING
untrusted input

Policy trace

High-risk action held for approval

Audit trail

The risk

A single poisoned document in your index can carry hidden instructions that the model obeys, turning a helpful RAG agent into an exfiltration or sabotage tool.

How Agentshield handles it

Agentshield treats retrieved documents as untrusted input and scans them for indirect injection before they shape an action. It constrains what the RAG agent may do with what it read, applies data-loss prevention on any outbound data, and records every retrieval-driven action in the audit trail so you can trace which source caused what.

How RAG becomes an attack surface

Retrieval-augmented generation works by pulling documents from an index and putting them into the model's context so it can answer from your data. That is also the problem. The retrieved text is untrusted, and the model reads it as if it were instructions. An attacker who can get content into your index, or into a page your agent fetches, can plant instructions the agent will obey. This is indirect prompt injection, and RAG is its most common home.

VectorHow the injection gets inThe control that stops it
Poisoned documentA file uploaded to the knowledge base hides instructions in its textInspect retrieved content for injection before it shapes an action
Compromised web sourceA page the agent browses carries hidden directivesTreat fetched content as untrusted, scan it, gate the resulting action
Shared or multi-tenant indexOne tenant's document steers another tenant's agentScope retrieval and enforce per-agent data permissions
Vector store loaded from an untrusted fileA malicious index file becomes code execution, as in the FAISS pickle issue CVE-2024-5998Validate index files by hash and patch the loader. See LangChain security
Data exfiltration via answerThe injected instruction tells the agent to send data outData-loss prevention on egress, block unauthorized destinations

The common thread is that the danger enters through the content itself, not through the user's question. We go deep on the mechanism in indirect prompt injection.

How to secure a RAG pipeline

Securing RAG is not about trusting your documents more. It is about assuming any retrieved text could be hostile and putting controls between retrieval and action. Work through these stages:

  1. Inspect retrieved content. Scan documents and fetched pages for injection before they enter the context that drives a decision, not after.
  2. Scope retrieval. Limit each agent to the sources and tenants its job requires, so a poisoned document in one corpus cannot reach an agent that should never see it. This is least-privilege access control applied to data.
  3. Constrain the action. Decide what the RAG agent may do with what it read. Reading a document should not grant the power to email, delete, or call an external tool without policy.
  4. Prevent data leakage. Apply data-loss prevention on anything the agent tries to send outward, so an injected instruction cannot turn retrieval into exfiltration.
  5. Record every retrieval-driven action. Log which source influenced which action, so when something goes wrong you can trace it to the document that caused it.

These map directly onto the OWASP LLM Top 10, where indirect injection and sensitive data disclosure sit near the top for retrieval systems.

FAQ

Common questions about rag security.

What is a secure RAG pipeline?

A secure RAG pipeline is a retrieval-augmented generation system hardened against indirect prompt injection and data leakage. Because RAG feeds retrieved documents into the model as context, a poisoned document can carry hidden instructions the agent obeys. Securing the pipeline means inspecting retrieved content for injection before it drives an action, scoping which sources each agent may read, constraining what the agent can then do, and blocking sensitive data from leaving to unauthorized destinations.

What is indirect prompt injection in RAG?

Indirect prompt injection in RAG is an attack where malicious instructions are hidden inside a document or web page that the pipeline retrieves, rather than typed by the user. When the model reads that retrieved text as context, it can obey the hidden instructions, so a single poisoned source can hijack an otherwise trusted agent into leaking data or taking an unsafe action. It is the primary security risk unique to retrieval systems.

How do you prevent prompt injection in a RAG system?

You prevent it by treating every retrieved document as untrusted input and inspecting it for injection before it enters the context that drives an action, then constraining what the agent may do with what it read. Add least-privilege scoping so an agent only retrieves the sources it needs, data-loss prevention on egress, and an audit trail that ties each action to its source. Tuning the prompt alone does not stop it.

Can a RAG pipeline leak sensitive data?

Yes. A RAG agent can leak data two ways: by retrieving documents a user should not have access to and surfacing them in an answer, or by being injected into sending data to an unauthorized destination. Both are contained by scoping retrieval to per-agent permissions and applying data-loss prevention on anything the agent sends outward, so retrieval cannot become an exfiltration channel.

Secure your rag security.