Data Leakage
Containing every copy
Leakage means model-visible data escaping the system: via responses, logs, embeddings, memory, or evals/training. Containment is about every copy — because models amplify whatever they can reach.
What you will learn
- Map where data copies live
- Test for cross-tenant leakage
- Scrub logs and embeddings
What is this?
Data leakage is confidential material appearing where it shouldn't: in another tenant's response, in logs, in embedding stores, in memory, or in training/eval data. Prevention is copy control: tenant isolation at every store, PII scrubbers on outputs and logs, and minimal-data principles.
Why do you need it?
- LLM pipelines copy data into many new places (caches, vectors, memory).
- Cross-tenant leakage is the highest-severity failure class.
- Embeddings retain retrievable secrets — hidden exfiltration channel.
- Once data lands in logs/training, recall is nearly impossible.
Mental model
Shredding vs. storing in one shared bin
Leakage
A hospital that keeps patient charts in a single shared drawer is leaking by architecture. Proper practice: separate lockers per tenant (isolation), destroy copies on release (scrubbers), and know where every copy lives (inventory). Leakage rarely 'happens'; it's designed in.
How it works
- Inventory wherever data copies land: context, vectors, memory, logs, caches.
- Enforce tenant isolation per store (scoped keys).
- Scrub PII from outputs, logs, and eval sets.
- Restrict what embeds/memory retain (minimal + ttl).
- Test leakage: cross-tenant probes in CI.
Copy inventory.
In production
- Multi-tenant chat enforces scoped vector/memory namespaces.
- Log pipelines strip messages before retention.
- Embedding stores exclude confidential fields; ttl applied.
Best practices
- Tenant isolation: scope keys in every store, test it.
- Minimal data: send only what the task requires.
- PII scrub on every output AND every log line.
- Inventorize data copies; new store = new entry + test.
Common mistakes
- One shared vector index for all tenants (blend on retrieval).
- Logging full prompts 'for debugging' with no scrub.
- Cold eval sets seeded with live confidential conversations.
Common issues
Tenant A sees Tenant B dataUnscoped retrieval
Scope every query + index by tenant; add negative CI tests.
Data in training artifactsLive data harvested at eval
Re-identify + scrub before dataset publish; block known fields.
Debugging tips
- Cross-tenant hit → shared store missing scope; add tenant key + test.
- PII in logs to find → centralized scrub gate on log pipeline.
- Embedding recall leaks → exclude confidential fields from embedding input.
Interview checkpoint
Hands-on lab
- Model a request payload with secrets
- Mask sensitive keys before logging
- Verify raw secrets never reach log lines
Redact Before Logging
25 min · intermediate
Quick quiz
A hidden exfiltration channel is…
Per-tenant isolation in vector stores prevents blends.