threatdeck
Live 13:45 UTC ·

Learn / Securing LLM applications

Lesson 3 of 69 minReviewed

RAG and vector stores: access control, poisoning and leakage

Enforce document permissions at retrieval time, treat the corpus as an attack surface for poisoning, and protect embeddings as carefully as the text they came from.

Retrieval-augmented generation adds a data path to an LLM application: documents are chunked, embedded, stored in a vector database and pulled into the context when a question looks similar. Every step inherits the security properties of the data and adds some of its own. OWASP groups the failures under Vector and Embedding Weaknesses (LLM08): unauthorised access and leakage, cross-context leaks between users of a shared store, embedding inversion, data poisoning, and changes in model behaviour [1].

A RAG pipeline with access control enforced at retrieval Sources such as wikis, tickets and shared drives feed an ingest step that chunks text, creates embeddings and records the source permissions on every chunk. Chunks go into a vector store partitioned per tenant. At query time the retrieval step filters on the caller's identity and groups, supplied by the application server rather than by the model, before any chunk reaches the model. Poisoned or hidden text enters at the source and ingest steps, so it must be validated there. poisoning enters here Sources wikis · tickets · drives each with its own ACLs Ingest chunk · embed · validate copy ACL onto each chunk Vector store partitioned per tenant protect like the source filter here, not in the prompt Retrieve top-k WHERE acl matches the caller Model sees only allowed chunks Caller identity and groups, set by the app server
Copy source permissions onto chunks at ingest; filter by the caller's identity at retrieval.

Access control belongs in retrieval

A wiki page that only finance can read is still only for finance after it becomes a chunk. OWASP's first mitigation is permission-aware vector stores with fine-grained access control and strict partitioning of datasets [1]. PortSwigger's guidance for LLM features states the same rule from the other side: only give the model data that the lowest-privileged user of the feature is allowed to see [2]. In practice:

  • Record source ACLs (owner, groups, tenant, classification) as metadata on every chunk at ingest, and re-sync when permissions change.
  • Apply the filter inside the vector query using the caller's identity from your session, not a value the model or the client supplies.
  • Use separate indexes or namespaces per tenant when a filter bug would mean a cross-customer breach.
  • Never ask the model to withhold content the caller is not entitled to; once a chunk is in the context, it can be repeated.

The corpus is attack surface

Retrieval is a ranking step, and an attacker only has to get a chunk into the top results for the questions they care about. PoisonedRAG measured this: injecting five crafted texts per target question into a knowledge base of millions of texts produced the attacker's chosen answer about 90% of the time, and the existing defences the authors tested were insufficient [3]. MITRE ATLAS tracks the technique as RAG Poisoning (AML.T0070) [4].

Anything users or outsiders can write to is a poisoning path: shared drives, ticket comments, public web pages you crawl, uploaded CVs. OWASP recommends validating and authenticating sources, auditing for hidden content, and accepting data only from trusted sources [1]. Keep provenance on every chunk so an answer can be traced to the document that produced it, and treat retrieved text as untrusted input to the model, applying the patterns from the first lesson in this path.

Embeddings are not anonymised data

It is tempting to treat vectors as opaque numbers. Morris and colleagues showed otherwise: an iterative inversion method recovered 92% of 32-token inputs exactly from their embeddings, and extracted full names from a dataset of clinical notes [5]. A vector store holding embeddings of HR files is an HR data store.

RAG controls by stage
StageRiskControl
IngestPoisoned or hidden textSource allowlist, content validation, provenance metadata [1]
StoreInversion, bulk theftEncryption, network isolation, the source system's access model [1, 5]
RetrieveCross-user and cross-tenant leakageIdentity-keyed filters set server-side, per-tenant partitions [1, 2]
GenerateInjected instructions in chunksTreat chunks as data; no tools without the patterns from lesson 1
OperateUndetected abuseImmutable logs of what was retrieved for whom [1]

Try it on ThreatDeck

Self-check

4 questions

Pick an answer to see whether it is right and why. Only your score is saved, in this browser.

  1. Where should document-level permissions be enforced in a RAG assistant?
  2. What does the PoisonedRAG result show?
  3. A multi-tenant SaaS keeps all tenants in one vector index. The model generates the tenant filter as a tool argument. What is wrong?
  4. Which statement about embeddings is supported by research?

References

  1. LLM08:2025 Vector and Embedding Weaknesses. OWASP GenAI Security Project, 2024-11.
  2. Web LLM attacks. PortSwigger Web Security Academy.
  3. PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models. Zou et al. (arXiv:2402.07867), 2024-02.
  4. MITRE ATLAS (Adversarial Threat Landscape for AI Systems). MITRE.
  5. Text Embeddings Reveal (Almost) As Much As Text. Morris et al. (arXiv:2310.06816), 2023-10.
Completing the self-check also marks the lesson complete. Saved in this browser only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.