Skip to content
VITI Security

RAG Security: How Your Internal Knowledge Base Becomes an Attack Vector

by VITI Security TeamMay 12, 2026
RAG Security: How Your Internal Knowledge Base Becomes an Attack Vector - VITI Security

Retrieval-augmented generation (RAG) is the most-deployed LLM pattern in production: an internal knowledge base, a vector index, a chat interface. It is also the pattern with the freshest set of vulnerabilities — because every document you index is a potential prompt-injection payload.

The trust boundary that does not exist

In a normal application, you treat user input as untrusted and database content as trusted. In RAG, the database content is whatever someone put into it — Confluence pages, Slack exports, customer tickets, call transcripts. That trust boundary collapsed and most teams have not updated their threat model yet.

Three concrete attacks we see

  • Indirect prompt injection. A malicious user (or an insider, or an attacker who got into one source system) plants a "remember this instruction" payload in a document. The next time a different user queries something that retrieves that document, the agent obeys.
  • Selective exfiltration. An attacker queries the assistant in a way that combines disjoint information across documents to expose data no single user should see (cross-doc inference).
  • Source poisoning. The attacker convinces the system to ingest a fabricated document that backs up a fake claim — used for fraud, false context in disputes, or undermining decision-making.

What defenders should add

  • Authenticate every retrieved document by source. Drop or flag any chunk whose origin is not in your trust set.
  • Strip prompt-like patterns at index time. "Ignore previous instructions" should never reach a model verbatim from RAG content.
  • Tag documents with the user/group authorized to see them. Filter retrieval by the requesting user's entitlement, not just by relevance.
  • Log every retrieval. If an unexpected document keeps appearing in answers, investigate.
  • Treat the LLM's output as untrusted just like user input — sanitize before logging, displaying, or feeding into downstream automation.

What about embeddings privacy

Embeddings are not "anonymous" — they preserve enough information to reconstruct meaningful chunks of the source. Treat your vector index with the same access controls as the underlying documents.

The hardening order that works

Most teams skip straight to output-side guardrails. The high-leverage moves are upstream: ingest-time sanitization, source attribution, retrieval-time filtering by user entitlement. Get those right and 80% of the realistic attack surface is gone.

Need help threat-modeling your RAG application? Our cybersecurity team runs LLM and RAG-specific assessments.

rag security attack vector

Further reading

Frequently asked questions

Why is RAG content a trust problem?

In a normal application, you treat user input as untrusted and database content as trusted. In RAG, the database content is whatever someone put into it - Confluence pages, Slack exports, customer tickets, call transcripts.

What defences should a RAG system add?

Authenticate every retrieved document by source. Drop or flag any chunk whose origin is not in your trust set. Strip prompt-like patterns at index time.

Are embeddings private?

Embeddings are not "anonymous" - they preserve enough information to reconstruct meaningful chunks of the source. Treat your vector index with the same access controls as the underlying documents.