AI Safety & Security / Attack Surfaces
Attacks on the data around a model.
Reviewed by Yuvaraj
Every model is shaped by data, and every deployment keeps data moving, into training sets, into vector stores, into prompts, and back out through generations, telemetry, and logs. Two mirror-image risks live in that flow. Leakage is sensitive data escaping the system: memorized training examples, personal information in outputs, or secrets captured in logs. Poisoning is malicious data entering the system: corrupted training examples that install hidden behavior, or planted documents that a retriever later surfaces as if they were trustworthy. We treat them together because they share one root cause, an ungoverned data supply chain, and many of the same defenses.
It helps to picture the data supply chain as a pipe with several inlets and outlets: the pretraining corpus, the fine-tuning set, the RAG knowledge sources, the live prompt, and the logs and feedback that flow back into future training. Leakage is data leaving through an outlet that should have been closed. Poisoning is data arriving through an inlet that should have been guarded. The same control, knowing the provenance of every record and enforcing a boundary at each stage, defends both directions, which is why a team that governs its data pipeline well tends to reduce both risks at once.
Training-data memorization. Because language models are trained to predict the next token, they can retain verbatim sequences from the corpus. Memorization is strongest for content that is duplicated across many documents and for high-entropy, unique strings such as keys, tokens, or identifiers, which the model can only reproduce by having stored them. Larger models and longer training memorize more.
Deduplication is a privacy control
Duplication is the single biggest driver of memorization: a string repeated thousands of times across the corpus is far more likely to be reproduced verbatim than one seen once. This is why corpus deduplication is not just an efficiency tactic, it measurably lowers extraction risk before any model is trained. Differentially private training (DP-SGD) goes further by bounding how much any single record can influence the weights, quantified by a privacy budget , where a smaller gives a stronger guarantee at some cost to utility.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
Extraction. With query access alone, an adversary can attempt to elicit memorized content, and research has repeatedly shown that portions of training data can be recovered this way. The related membership inference question, "was this specific record in the training set?", matters on its own when membership is itself sensitive, for example whether a particular patient record was used.
PII in outputs. Personal data reaches outputs by two paths. It can be regurgitated from training if PII was present in the corpus, or it can be echoed from inference time when a user pastes personal data into a prompt and it later resurfaces, in that same session, in logs, or, worst of all, to a different user through a shared cache or cross-tenant contamination.
Leakage via logs and prompts. The prompt itself is often sensitive: system prompts embed internal instructions and sometimes credentials, and user prompts carry whatever the user typed. That content is routinely copied into request logs, analytics, error traces, and third-party telemetry, and, critically, into feedback datasets used for future fine-tuning. Each copy is a place the data can escape.
Sensitive data in a vector store. A RAG index stores chunks of source text plus metadata. Two failures dominate. First, broken authorization at retrieval: if the query does not filter by the requesting user's permissions, someone can retrieve chunks they were never allowed to read. Second, the embeddings are not opaque, embedding-inversion research shows that text can be partially reconstructed from its vector, so the index must be treated as sensitive data, not as a harmless numeric cache.
The vector store is production data
Treat the vector database with the same rigor as the source database it was built from: least-privilege access, encryption at rest, per-tenant partitioning, and data-retention limits. Copying documents into an index does not strip their sensitivity, it duplicates it into a system that is often less well governed than the original store.
Training-data poisoning. An adversary injects crafted examples into the training or fine-tuning corpus. The goal may be availability (degrade overall accuracy) or, more dangerously, integrity (install a specific targeted behavior). Web-scale scraping makes injection realistic: content can be placed where crawlers will find it, and studies have shown that controlling even a tiny fraction of a corpus can be enough for a targeted effect.
Backdoors and triggers. A backdoor is a hidden association the model learns between a trigger, a rare token, phrase, or stylistic pattern, and an attacker-chosen behavior. The model behaves normally on clean inputs and flips only when the trigger appears. This is what makes backdoors so hard to catch: clean-input accuracy is unchanged, so standard evaluation on a held-out set looks perfectly healthy. The canonical demonstration, BadNets, showed this in image classifiers, and the same principle applies to language models.
RAG poisoning. Here the weights are never touched. The attacker plants content in a source that the ingestion pipeline trusts, a public wiki, a shared drive, a scraped site, and writes it to be semantically close to the questions real users will ask. Retrievers rank candidate chunks by embedding similarity, most often cosine similarity:
so content engineered to sit near likely queries in vector space will be retrieved and dropped into the context window, where the model tends to treat it as authoritative. If the payload is a false fact, the model repeats misinformation; if the payload is an instruction, RAG poisoning becomes a delivery vehicle for indirect prompt injection.
No single control is sufficient; each stage of the pipe needs its own guard, and the earliest effective control is almost always the cheapest.
Consider a customer-support assistant that answers from a knowledge base. Among its curated sources, the ingestion job also pulls from a community wiki that any user can edit. An attacker adds a page written to match common billing questions, and embeds a payload, a false instruction telling users to send account details to an external address. Follow the request through the pipeline and note where each control can break the chain.
The lesson of the trace is defense in depth: the payload has to survive every stage to cause harm, so even imperfect controls compound. Vetting at ingestion is the strongest and cheapest guard, but trust tiers, retrieval-time access control, and citations each give an independent chance to break the chain.
| Threat | Mechanism | Primary defense |
|---|---|---|
| Training-data memorization | Verbatim retention of duplicated or high-entropy sequences | Corpus deduplication, PII scrubbing before training, DP-SGD where feasible |
| Training-data extraction | Crafted queries elicit stored content via query access | Output filtering, rate limiting, memorization and canary audits |
| PII in outputs | Model regurgitates corpus PII or echoes inference-time PII | Input and output redaction, minimize logging, isolate tenants |
| Leakage via logs and prompts | Secrets in system prompts and telemetry get captured | Secret management, log redaction, no-train flags on prompt data |
| Sensitive data in a vector store | Chunks retrievable without authorization; embedding inversion | Retrieval-time access control, per-tenant partitioning, encrypt and minimize |
| Training-data poisoning | Injected examples corrupt learned behavior | Provenance and vetting, integrity checks, anomaly detection |
| Backdoor / trigger | Hidden trigger-to-behavior link; clean accuracy intact | Trusted sources and weight verification, trigger scanning, fine-pruning |
| RAG poisoning | Malicious content planted in an ingested source and later retrieved | Source allowlisting, trust tiers, content sanitization, provenance in context |
Common mistakes