Runtime security for retrieval-augmented generation pipelines
A retrieval-augmented generation pipeline pulls outside text into the prompt, so a poisoned document can steer the model. Controls belong at retrieval, at the prompt and at the output. Sources read on 16 Nov 2026 include OWASP's vector weaknesses entry and NeMo Guardrails retrieval rails.
Facts read on .
What can go wrong in a RAG pipeline at runtime?
Retrieved text enters the prompt as if it were trusted, so a document can carry instructions that change what the model does. Stored vectors can also expose data to users who should not see it. The same pattern holds for any pipeline that places text from a search index, a ticket system or a file share into a prompt, so treat all such text as untrusted input.
OWASP's 2025 list names LLM08 vector and embedding weaknesses and LLM01 prompt injection, which includes instructions hidden in retrieved content.
Sources: OWASP Top 10 for LLM Applications 2025.
Where should a control sit?
Put a control at each hop: on the retrieved chunks, on the assembled prompt and on the answer. NeMo Guardrails has retrieval rails for this, where a rail can reject a chunk and keep it from prompting the model, or alter it to mask sensitive data.
Azure's Prompt Shields include document attack detection, which analyzes supplied documents for attack patterns separately from the user's prompt.
Sources: NVIDIA NeMo Guardrails; Prompt Shields in Azure AI Content Safety.
How do you limit what retrieval can return?
Enforce the user's access rights at retrieval time, so the index returns only chunks the user may read. Filtering after the model answers is too late for data already in the prompt.
Add a data filter on the answer as well. Bedrock's sensitive information filters can block or mask personal data in model responses.
Sources: Amazon Bedrock Guardrails components.
What about agents that retrieve?
An agent that retrieves and then calls tools turns a bad document into an action. Authorize the tool call separately from the retrieval, as NeMo's execution rails do for tools the model calls.
HiddenLayer documents gates when tool output returns in coding agents, which is the same idea for content coming back from a tool.
Sources: NVIDIA NeMo Guardrails; HiddenLayer Agent Harness Security architecture.
How do you test it?
Seed a test index with harmless marker text that tries to change the model's behavior, and confirm each control catches it. Record which hop caught it and which did not.
Repeat after any change to the index, the prompt template or the guardrail policy.
What do the vendors say?
Vendor coverage of retrieval is thin. Cloudflare's AI Gateway DLP scans prompts and responses and, on a block, discards the provider response, and Palo Alto Networks documents a scan API that checks prompts and model responses for any model.
Neither page describes checking retrieved chunks as a named step, so ask vendors whether their check sees retrieved text.
Sources: Cloudflare AI Gateway DLP; Prisma AIRS API Intercept overview.
What is the minimum for a first rollout?
Start with access checks at retrieval, a prompt attack check on the assembled prompt and an output filter. Log which documents were retrieved for each answer so a bad answer can be traced to its source.
Add document scanning at ingest when you can, and re-scan on a schedule.
Sources: Prompt Shields in Azure AI Content Safety; Amazon Bedrock Guardrails components.
Which signs show a poisoned source?
Watch for answers that suddenly cite one document, for retrieved text containing instructions addressed to the model, and for tool calls that follow a retrieval with no user request.
Log the source of each chunk so a suspect document can be removed and the affected answers found.
Sources: OWASP Top 10 for LLM Applications 2025.
Sources
- OWASP Top 10 for LLM Applications 2025 (genai.owasp.org), read
- NVIDIA NeMo Guardrails (github.com), read
- Prompt Shields in Azure AI Content Safety (learn.microsoft.com), read
- Amazon Bedrock Guardrails components (docs.aws.amazon.com), read
- HiddenLayer Agent Harness Security architecture (docs.hiddenlayer.ai), read