Part 6 · LLM Application Security
LLM09: Vector and Embedding Weaknesses
Similarity search becomes part of the trust boundary whenever it decides what a model gets to read.
What it is
Vector and embedding weaknesses affect any system that converts content into embeddings and uses similarity search to choose what the model sees. That includes RAG, vector-backed agent memory, semantic caches, and deduplication pipelines.
These weaknesses exploit the embedding layer itself: how content is stored, separated, ranked, and retrieved.
How the attack unfolds
A filter applied after retrieval is too late. Tenant scope must be part of the index query.
Main weaknesses
| Weakness | What happens |
|---|---|
| Cross-tenant leakage | One customer's content is retrieved for another |
| Retrieval manipulation | Crafted content ranks highly for chosen queries |
| Embedding inversion | Original text is partly reconstructed from vectors |
| Semantic cache poisoning | A bad answer is reused for similar questions |
| Hidden document content | Invisible text is indexed but unseen by reviewers |
Defenses
- Scope inside the query. Enforce tenancy and permissions in the index itself.
- Control access per chunk. One document can contain a confidential paragraph.
- Normalize before embedding. Remove zero-width characters and hidden text.
- Track provenance. Record each embedding's source so bad batches can be removed.
- Separate trust tiers. Keep untrusted and verified sources apart.
- Protect embeddings. Treat vectors as sensitive derived data.
Common misconception
Common belief
"Embeddings are just numbers, so they are not sensitive."
In practice
Research has shown that much of the original text can sometimes be recovered from embeddings.
Key takeaways
- Similarity search can cross tenant or permission boundaries.
- Enforce access control inside the query.
- Treat embeddings as sensitive derived data.