π What Is It?
Vector & Embedding Weaknesses are security flaws in how embeddings are generated, stored, and retrieved in Retrieval-Augmented Generation (RAG) systems β a new category in the 2025 edition. The unifying theme: a RAG system treats whatever the retriever returns as trusted, authoritative context. If an attacker can influence what is retrieved, who can retrieve it, or what the stored vectors reveal, they can steer answers, exfiltrate other users' data, or reconstruct source text β often without ever touching the model. Two hard truths: similarity is not authorization, and vectors are lossy but not one-way (they can be inverted back toward text).
β οΈ Top Attack Vectors
- Cross-tenant retrieval: shared index, no tenant filter β user A surfaces tenant B's chunks.
- Over-permissioned retrieval: god-mode service account launders HR/legal docs past file ACLs (confused deputy).
- Knowledge poisoning: attacker edits an ingested wiki/ticket/upload; false "facts" rank top-k.
- Indirect prompt injection: hidden instructions in a retrieved doc fire in context (LLM08βLLM01 bridge).
- Embedding inversion: leaked vectors reconstructed back toward source text (vec2text).
- Embedded secrets: credentials in ingested docs become searchable and retrievable.
π― Three Intents
- Read what you shouldn't: abuse retrieval for other users' chunks, or invert stored vectors.
- Write what shouldn't be trusted: poison the corpus at ingestion so bad docs get retrieved later.
- Steer what gets retrieved: craft content that outranks legitimate context (a "context conflict").
None require breaking the model's weights β they exploit the retrieval pipeline that sits outside the app's normal authz checks.
π΄ Attack Flow
β
2. Choose a lever β retrieval abuse / ingestion poison / ranking attack / inversion
β
3. Trigger β ask a question that routes the payload / target chunk into context
β
4. Context treated as trusted, authoritative material
β
5. IMPACT: read leaked data, hijack the answer, run injected instructions!
β Vulnerable Code (pgvector)
β Secure Code (pgvector)
β Prevention Checklist
- Per-tenant namespace/collection derived from the verified session (not client input)
- Server-side metadata ACL filter on every query; pre-filter, never post-filter
- Retriever runs as the asking user, not a god-mode service account
- Validate, attribute (provenance), and approve documents before indexing
- Scan and redact secrets out of documents before embedding
- Treat retrieved content as untrusted data β delimit, label, strip hidden text
- Encrypt the index at rest and in transit; keep it off the public internet
- Least-privilege, per-service, rotated vector-store API keys
- Log retrieval, alert on anomalies, keep answerβsource traceability