Topic 4 of 4 · 4 min read
Personal and secret data in vector indexes
Goal: Write an ingestion rule set that redacts or excludes personal data and secrets before embedding.
Decide what must never be indexed, and remove it before chunking and embedding, because everything you put in the index can be retrieved, logged and sometimes reconstructed.
Check yourself · 1 of 3
Why should redaction run on the whole document before chunking?
Why it matters
Chunks keep the original text next to the vector, so any email address, national id, API key or medical note in a source document is now in a second database with its own backups, logs and access rules. The vectors themselves are not safe either. OWASP's vector and embedding risk page (LLM08:2025) lists embedding inversion: research shows that text can be partly recovered from its embedding, so a leaked vector store should be treated as leaked data. Deleting a customer under privacy law means deleting their chunks and vectors too.
How to do it
- Write a data policy first. List what is excluded (secrets, health records, card numbers), what is redacted (names, emails, phone numbers) and what is allowed with controls.
- Redact before chunking, not after. A chunk boundary can split a key or an id so a pattern no longer matches. Scan the whole document, then chunk.
- Use more than one detector. Regex and checksum rules for keys and card numbers, a PII model or service for names and addresses. Replace values with typed placeholders such as
[EMAIL], so meaning survives. - Exclude by location. Skip folders, tables and file types known to hold secrets:
.env, credential exports, HR case files. - Make deletion possible. Store a document id and subject id on each chunk so you can delete by person or by source and re-index.
- Apply the policy to logs, traces and caches. Prompts and retrieved chunks often land in observability tools. Redact there too, set short retention and restrict access.
- Test with canaries. Plant fake secrets and a fake person in a test source, then check they never appear in the index, logs or answers.
Before and after
Before: a support-ticket export goes straight to the embedder, so a ticket reading "My card 4111 1111 1111 1111 was declined, call me on 555-0100" is searchable and quotable. After: a rule set removes the card number, replaces the phone with [PHONE] and keeps ticket_id for deletion.
exclude_paths: ["**/.env", "hr/cases/**"]
redact:
card_number: drop_chunk
email: "[EMAIL]"
phone: "[PHONE]"
api_key_patterns: drop_document
metadata_required: [doc_id, subject_id, source]
log_retention_days: 14
What goes wrong
- Redacting after chunking, so split values slip through.
- Cleaning the index but not the logs, which keep full prompts.
- No subject id, so a deletion request cannot find the chunks.
Examples
The key split by a chunk boundary
A config file has API_KEY=sk_live_...redacted that straddles two 500-token chunks. A regex run per chunk matches neither half. Running detection on the whole file first would have caught it, and a path rule excluding .env files would have kept the file out entirely.
The deletion request
A user asks to be erased. The CRM row is deleted, but their name sits in 14 chunks, in a cached answer and in last week's prompt logs. With subject_id on each chunk the vectors are removed by one query, and the logs expire on their retention schedule. Without it, finding the chunks means searching text by hand.
Key points
- Chunks hold original text, so anything in a source document becomes retrievable and quotable.
- Embeddings can be partly inverted back to text, so a leaked vector store counts as leaked data.
- Redact or exclude on the whole document before chunking, using several detectors.
- Keep document and subject ids on chunks so you can delete one person's data and re-index.
- Apply the same rules to logs, traces and caches, and test them with planted canary values.
Common mistakes
- Running PII detection on each chunk instead of the whole document.
- Cleaning the index while prompts and retrieved chunks are logged in full.
- Believing vectors are anonymous because they look like numbers.
- Indexing a whole drive or database export without a list of excluded paths and fields.
Check yourself · 2 of 3
What does the embedding inversion risk mean for a vector store with sensitive documents?
Check yourself · 3 of 3
A user asks you to erase their data. What must the index already have for this to work?
Practice items, not counted towards your mastery.
Start here
- LLM08:2025 Vector and Embedding Weaknesses (OWASP GenAI) (opens in a new tab)DocsFree
Names access-control gaps, data poisoning and embedding inversion as the core risks of vector stores.
- PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation (opens in a new tab)PaperFree
The research behind planting a few texts in a knowledge base to steer answers for chosen questions.
- Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection (opens in a new tab)PaperFree
The paper that named indirect prompt injection and showed it against retrieval-based apps.
More for this topic
- LLM02:2025 Sensitive Information Disclosure (OWASP GenAI) (opens in a new tab)StandardFree
Covers personal data and secrets leaking through model inputs and outputs, and sanitisation controls.