Poisoning a Vector Index in 4 Documents: The Flaw Your Pentest Never Looked For
Poisoning a Vector Index in 4 Documents: The Flaw Your Pentest Never Looked For
Complete attack, detection and defense guide for RAG systems in production
ZEROLUME · War Room #4 · Pillar 4 — Zero Terminal By LEBONI BAKLA Lionel — ARCH-REV Reading time: 18 minutes
TL;DR — 4 well-written documents, dropped in the right spot in your vector database, are enough to hijack 100% of your AI assistant’s answers. No CVE. No signature. No log. No alert. Your classic pentest would never have found it, because the flaw is not in the code: it is in the content. This article explains the full attack chain, the countermeasures that don’t work, the ones that do, and the deliverable of a real AI audit.

🎥 Full video (War Room #4 — Zero Terminal): https://www.youtube.com/watch?v=viaAZlC15gY&t=274s
Table of contents
- Your report is green. Every box is ticked.
- RAG in 60 seconds
- Why the classic pentest is blind to AI
- The attack chain in 3 steps
- The lab: numbers, architecture, results
- What does NOT work (and why)
- What works: defense in depth
- The deliverable of a REAL AI audit (RAG-AUD)
- Compliance: EU AI Act, OWASP, NIST
- The lab: 12 tests before shipping an agent to prod
- Resources and references
1. Your report is green. Every box is ticked.
That is the sentence that opens War Room #4, and it is the starting point of this article. If you have a RAG in production — an assistant that answers over your documents, your tickets, your knowledge base, your contracts — you are concerned. Not tomorrow. Today.
An attacker hijacks your assistant by slipping 4 documents into your vector database. No CVE. No signature. No log. No alert. Your pentest never looked for it — and for good reason: the flaw is not in the code, it is in the content.
The rest of this article is a complete guide: attack, detection, defense, audit, compliance. Everything you need to know so you are not the next one.
2. RAG in 60 seconds
Before attacking, you have to understand the target. A RAG (Retrieval-Augmented Generation) system is made of four building blocks:
[Documents] → [Chunking] → [Embeddings] → [Vector DB] → [Retriever] → [LLM] → [Answer]
- Ingestion: documents are split into chunks (often 512 tokens), then converted into vectors (embeddings) by an embedding model (often 384 dimensions).
- Storage: the vectors are stored in a vector database (Qdrant, Pinecone, Weaviate, Milvus, pgvector) with an HNSW index for approximate search.
- Retrieval: when the user asks a question, it is converted into a vector, and the retriever returns the top-k most similar chunks (cosine similarity).
- Generation: the LLM receives the chunks as context and generates an answer.
The key point: the LLM does not know whether the context it is given is trustworthy. It trusts the retrieval. And the retrieval trusts cosine similarity. And cosine similarity trusts the content.
That chain of trust is what is going to be exploited.
3. Why the classic pentest is blind to AI
A classic pentest compares your system against a database of known flaws. It hunts deterministic vulnerabilities: SQL injection, XSS, SSRF, misconfiguration, exposed secrets. It is excellent at that — it is its job.
But a RAG is a probabilistic system. Its answer depends on what the retrieval brings back, and what the retrieval brings back depends on the cosine similarity between the question and the chunks. The scanner, on the other hand, reasons deterministically. Two worlds that do not talk to each other.
| What the pentest tests | What the pentest ignores |
|---|---|
| SQL injection | Cosine similarity |
| Reflected XSS | Chunk provenance |
| SSRF | Retrieval anomalies |
| Plaintext secrets | Model confidence |
| TLS configuration | Corpus poisoning |
| Vulnerable dependencies | Uncontrolled ingestion |
Result: the scanner validates your application, your infrastructure, your dependencies. It never validates the content the AI is going to consume. And that is exactly where the flaw hides.
The scanner hunts deterministic vulnerabilities in a probabilistic system.
4. The attack chain in 3 steps
Poisoning a vector index unfolds in three moves. Eight seconds. Zero alerts.
Step 1 — Ingestion: 4 docs slipped in without an alert
The attacker drops 4 well-written documents into your ingestion pipeline. The entry vectors are numerous:
- A publicly writable S3 bucket
- An upload form with no content validation
- An overly permissive SharePoint connector
- An unauthenticated ingestion API endpoint
- A Word/PDF document with manipulated metadata
- An email automatically ingested into the knowledge base
No alert fires: the documents are syntactically valid, well-formed, plausible. They talk about the targeted subject, using the domain’s vocabulary. Nothing distinguishes them from a legitimate document at the syntactic level.
What makes the attack invisible: the document is not malicious in its form. It is malicious in its intent. No malware scanner will detect it, because there is no executable payload. It is text. Well-written text.
Step 2 — Retrieval: the poison surfaces top-3
When a user asks a question, the retriever computes the cosine similarity between the question and the chunks. The poisoned documents are written to maximize that similarity: they reuse the question’s vocabulary, technical terms, acronyms, product names.
Lab observation:
| Chunk | Cosine similarity |
|---|---|
| Poison 1 | 0.89 |
| Poison 2 | 0.87 |
| Poison 3 | 0.84 |
| Legitimate document | 0.62 |
| Retrieval threshold | 0.70 |
The 3 poisoned chunks surface in the top-k (top-3). The legitimate document, at 0.62, does not pass the 0.70 threshold. It is eliminated.
Why it works: the retriever does not know what is true. It knows what is similar. And cosine similarity does not distinguish a factual document from a fabricated one using the same vocabulary.
Step 3 — Generation: the LLM cites the poison
The LLM receives the 3 poisoned chunks as context. It generates a coherent, well-written answer, citing sources. Model confidence: 0.91.
The user receives an official, credible — and false — answer. They have no reason to doubt it: the answer is well formulated, cited, in the company’s tone.
The danger: the poisoned answer triggers no alert. The LLM emits no warning. The retrieval logs no anomaly. The user does not know they received a manipulated answer.
5. The lab: numbers, architecture, results
Lab architecture
| Component | Value |
|---|---|
| Chunking | 512 tokens |
| Embeddings | 384 dimensions |
| Vector DB | Qdrant (HNSW) |
| Top-k | 3 |
| Similarity | Cosine |
| Threshold | 0.70 |
| Corpus | 12,847 documents |
Results
| Metric | Value |
|---|---|
| Poisoned documents | 4 |
| % of corpus | 0.03% |
| Chunks surfaced (poison) | 3/3 |
| Max similarity (poison) | 0.89 |
| Similarity (legit) | 0.62 |
| Model confidence | 0.91 |
| Hijacked answers | 100% |
| CVE exploited | 0 |
| Signature detected | 0 |
| Log generated | 0 |
| Alert triggered | 0 |
The number that hurts
4 documents out of 12,847 = 0.03% of the corpus.
0.03% is enough to return 100% of the answers on the targeted subject. No CVE. No compromised server. Four well-written documents, dropped in the right place.
Three sources cited, three sources poisoned. Public S3 bucket. Plaintext API key.
6. What does NOT work (and why)
We tested the classic countermeasures. All bypassed.
Output filter
The poison is worded to pass lexical filters. It uses domain vocabulary, not suspicious keywords. The filter sees normal text and lets it through.
Why it fails: the filter validates the form of the answer, not the provenance of the content. A well-written malicious text passes every lexical filter.
Keyword blacklist
The vocabulary used is the business domain’s. Nothing to blacklist without also blocking legitimate content.
Why it fails: the blacklist is a finite list facing an infinite vocabulary. The attacker rephrases, and the filter becomes useless.
Judge model
A second LLM tasked with validating the answer is itself trapped by the poisoned context. It receives the same chunks and concludes the answer is coherent.
Why it fails: the judge model is also a probabilistic system. It trusts the same context. Two LLMs validating each other on the basis of the same poison is two blind men guiding each other.
Summary
| Countermeasure | Effectiveness | Reason for failure |
|---|---|---|
| Output filter | ❌ | Validates form, not provenance |
| Keyword blacklist | ❌ | Domain vocabulary, nothing to blacklist |
| Judge model | ❌ | Same poisoned context, same blindness |
| Prompt hardening | ❌ | The poison is in the context, not the prompt |
7. What works: defense in depth
Defense sits upstream, at the pipeline level. Four mechanisms, combined.
7.1 Sign provenance at ingestion
Every chunk carries the signature of its source. A chunk that is unsigned or signed by an unauthorized source is rejected before entering the index.
Implementation:
- Cryptographic hash of the source + signature (HMAC or asymmetric key)
- Verification at ingestion: if the signature does not match, the chunk is rejected
- Provenance stored in the chunk’s metadata
What it blocks: the attacker cannot inject chunks without access to the signing key. Even if they drop a document into the pipeline, the chunk will be rejected.
7.2 Detect similarity anomalies
A cluster of chunks with abnormally high similarity among themselves (but not with the rest of the corpus) is a poisoning signal.
Implementation:
- Compute similarity density per cluster
- Alert threshold if a group of chunks has internal similarity > 0.95 but similarity with the corpus < 0.50
- Real-time alerting on newly ingested chunks
What it blocks: even if the attacker signs their chunks (key compromise), the similarity anomaly triggers an alert.
7.3 Audit the retrieval, not just the answer
Log what surfaces, not what is generated. That is where the attack plays out.
Implementation:
- Log every request: question, surfaced chunks, scores, sources
- Monitoring dashboard: score distribution, most frequent sources, anomalies
- Alerting if a chunk appears in > X% of answers on a subject
What it blocks: the attack becomes visible. Even if it passes, it leaves auditable traces.
7.4 Correct and retest
Delete the compromised chunks, re-ingest, then retest the whole pipeline.
Implementation:
- Rollback procedure: delete chunks by provenance
- Clean re-ingestion from the source of truth
- Automated retest with the lab (12 tests)
- Validation that the hijacking rate is back to 0
What it blocks: resilience. Even if the attack succeeds, recovery is fast and verified.
Defense summary table
| Mechanism | Layer | Blocks | Detects | Recovers |
|---|---|---|---|---|
| Provenance signing | Ingestion | ✅ | — | — |
| Similarity anomaly | Ingestion | — | ✅ | — |
| Retrieval audit | Retrieval | — | ✅ | — |
| Correct + retest | Pipeline | — | — | ✅ |
8. The deliverable of a REAL AI audit (RAG-AUD)
A serious RAG audit is not a scan. It contains 8 sections:
| Section | Content |
|---|---|
| 1. Hijacking rate | Empirical measurement on N target questions |
| 2. Provenance | Source mapping, signatures, trust chain |
| 3. Retrieval | Similarities, top-k, thresholds, anomalies |
| 4. Generation | Confidence, hallucination, citation, coherence |
| 5. Confidence levels | Per answer, per subject, per source |
| 6. Ingestion vectors | Exposed endpoints, connectors, permissions |
| 7. Countermeasures | Tested, effectiveness, bypasses |
| 8. Retest at D+30 | Validation that the fixes hold |
Duration: 5 to 10 days. Scope: the pipeline, not the storefront. Deliverable: report + debrief + retest.
9. Compliance: EU AI Act, OWASP, NIST
EU AI Act — Articles 9, 15, 43
- Article 9: risk management system. Corpus poisoning is an identified risk to manage.
- Article 15: accuracy, robustness, cybersecurity. A system vulnerable to poisoning is not robust.
- Article 43: conformity assessment. Compliance is not measured by the green of a classic pentest report.
OWASP Top 10 for LLM Applications
- LLM03: Training Data Poisoning — poisoning training and retrieval data is a category of its own.
- LLM06: Sensitive Information Disclosure — a poisoned RAG can exfiltrate data through answers.
- LLM08: Excessive Agency — an agent with access to tools, fed a poisoned context, can act unintentionally.
NIST AI RMF
- Map: identify risks linked to ingested content.
- Measure: measure the hijacking rate, the robustness of retrieval.
- Manage: put countermeasures in place (provenance, anomaly, audit).
- Govern: document, audit, retest.
MITRE ATLAS
- AML.T0020: Poison Training Data — documented technique.
- AML.T0043: Craft Adversarial Data — creating data designed to maximize similarity.
10. The lab: 12 tests before shipping an agent to prod
We published a reproducible lab. Same stack as your prod. 12 tests to run before production deployment.
The 12 tests
- Unauthenticated ingestion — can a document be dropped without authentication?
- Ingestion without validation — is content validated before indexing?
- Missing provenance — do chunks carry a source signature?
- Abnormal similarity — does a cluster of chunks have abnormally high internal similarity?
- Unlogged retrieval — are requests and surfaced chunks logged?
- Threshold too low — does the similarity threshold let irrelevant chunks through?
- Top-k too large — does a large top-k increase the attack surface?
- Bypassable output filter — does the output filter block the poison?
- Bypassable judge model — does the judge model detect the poison?
- Exfiltration via answer — can the poison exfiltrate data through the answer?
- Recovery — can compromised chunks be deleted and cleanly re-ingested?
- Retest — after correction, is the hijacking rate back to 0?
BREACH code
The BREACH code gives access to the full lab. Request it by email.
Conditions
- Never in prod: always in an isolated lab.
- 30-min scoping call: we frame your scope and tell you what to test first.
- Report + debrief + retest at D+30.
11. Resources and references
Full video
🎥 War Room #4 — Zero Terminal: https://www.youtube.com/watch?v=viaAZlC15gY&t=274s
Social media
- 📱 TikTok: https://www.tiktok.com/@zerolumec9w
- 📸 Instagram: https://www.instagram.com/zerolumec9w
- 𝕏 X: https://x.com/zerolumec9w
- 📘 Facebook: https://facebook.com/zerolumec9w
- 💼 LinkedIn: https://www.linkedin.com/company/zerolume
- 📝 Medium: https://zerolumec9w.medium.com/
Referenced frameworks
| Framework | Application |
|---|---|
| RAG architecture | Chunking 512 tokens, embeddings 384d, Qdrant HNSW, top-k 3 |
| Cosine similarity | Poison 0.89 / 0.87 / 0.84 vs legit 0.62 — threshold 0.70 |
| EU AI Act | Articles 9, 15, 43 (robustness, assessment, continuous management) |
| OWASP | Top 10 for LLM Applications (LLM03, LLM06, LLM08) |
| NIST AI RMF | Map, Measure, Manage, Govern |
| MITRE ATLAS | AML.T0020, AML.T0043 |
Contact
📩 contact@zerolume.com | baklalionel@zerolume.com 👤 LEBONI BAKLA Lionel — ARCH-REV
Conclusion
Your pentest is green. Your AI is already hacked. Or not. You will never know until you test the content.
The flaw is not in the code. It is in the 4 documents nobody checked. 0.03% of the corpus. 100% of answers hijacked. 0 CVE. 0 signature. 0 log.
We do not run classic pentests. We break AIs in public — and we fix them.
Download the lab. Test. Fix. Retest.
ZEROLUME | Offensive AI Security War Room · Pillar 4 · Zero Terminal © 2026 ZEROLUME — All rights reserved