Training Data Leakage, Explained

Training data leakage is when information from the data used to build a model comes back out of the finished system. Someone queries the model, or the retrieval layer behind it, and gets content that was supposed to stay inside the training set. That content might be a customer record, a support transcript, a clinical note, or a credential that ended up in a log file shipped to a fine-tuning job.

At a glance
  • The mechanism is memorization. Models store some of what they are trained on rather than generalizing from it, and stored sequences can be pulled back out.
  • Five paths out. Verbatim extraction, membership inference, model inversion, property inference, and leakage through retrieval or fine-tuning context.
  • Alignment did not close it. A divergence attack against ChatGPT recovered over ten thousand unique memorized examples for roughly 200 dollars in API queries.
  • Controls belong upstream. Once a sequence is encoded into weights, the options narrow to retraining, unlearning, or output filtering.

The mechanism underneath most of it is memorization. Models store some of what they're trained on rather than generalizing from it, and stored sequences can be pulled back out. This page covers why memorization happens, the five paths data takes on its way out, what attacks actually recover, and where controls belong if you want them to work.

Verbatim extractionMembership inferenceModel inversionProperty inferenceRetrieval or fine-tuning context the model completes what it memorizedwas this record in the training setreconstruct attributes from outputswhat the dataset as a whole containedno weights involved, most common in production Deployed model query access only
Four of the five paths need nothing but query access to a deployed model. The fifth bypasses the weights entirely and reads from the retrieval index, which is why it shows up most often in production.

What is training data leakage?

Training data leakage is the recovery of training data content from a deployed model or its supporting pipeline. It covers exact text a model reproduces, facts an attacker infers about individuals, and records a retrieval system serves to the wrong user. The common thread is data crossing a boundary it was never meant to cross.

Common mistake

Treating the three failures as one. A model that reproduces a paragraph of your internal wiki, a RAG system that returns another department's documents, and an attacker who determines that a specific patient's record was in your fine-tuning set are all leakage. They have different root causes and different fixes, and merging them in incident response sends you after the wrong one.

Worth separating from a related term. In classical machine learning, data leakage often means test data contaminating the training set, which inflates evaluation scores. That is a correctness problem. The leakage on this page is a confidentiality problem, and the two share a name by accident.

OWASP catalogued the confidentiality version as LLM02:2025 Sensitive Information Disclosure in the OWASP Top 10 for LLM Applications 2025, where it moved up from sixth place in the previous edition to second. The listing explicitly names memorized training data alongside prompt and system-prompt disclosure.

Why do models memorize training data at all?

Memorization is a side effect of how models learn. Training minimizes prediction error over examples, and for rare or repeated sequences the cheapest way to reduce that error is to store the sequence rather than generalize from it. Carlini and colleagues showed in 2022 that memorization grows with model size, duplication, and context length.

That 2022 paper, Quantifying Memorization Across Neural Language Models by Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang, describes three log-linear relationships. Memorization increases with model capacity, with the number of times an example appears in the training data, and with the number of context tokens used to prompt the model. Their conclusion was that memorization is more prevalent than previously believed and gets worse as models scale, absent active mitigation.

Two practical consequences follow. First, deduplicating your corpus helps, because duplication is one of the three levers. Second, deduplication alone doesn't fix it, because the earlier USENIX Security 2021 work from the same group showed extraction succeeding on sequences that appeared in only a single document.

The uncomfortable part is that memorization isn't cleanly separable from capability. A model that can recall a specific API signature, a legal citation, or a drug interaction is doing something users want. The same storage behavior applied to a customer's address is a privacy incident. There's no switch that keeps one and drops the other.

What are the five paths training data gets out?

PathWhat an attacker getsWhere the data sits
Verbatim extractionTraining text the model emits word for wordModel weights
Membership inferenceWhether a specific record was in the training setModel weights
Model inversion and attribute inferenceReconstructed attributes of an individual, built from model outputsModel weights
Property inferenceProperties of the dataset as a whole, not of any individual in itModel weights
Retrieval or fine-tuning contextSource documents or assembled training files, served directlyRetrieval index or training files, not weights

Verbatim extraction and divergence attacks

The direct path. You prompt the model, and it completes with text it saw during training. Carlini et al. demonstrated this against GPT-2 in 2021, recovering hundreds of verbatim sequences including names, phone numbers, email addresses, IRC conversations, code, and 128-bit UUIDs.

Alignment training was widely assumed to have closed this. It didn't. In Scalable Extraction of Training Data from (Production) Language Models, published November 28, 2023, Milad Nasr, Nicholas Carlini, Jonathan Hayase, Matthew Jagielski, A. Feder Cooper, Daphne Ippolito, Christopher A. Choquette-Choo, Eric Wallace, Florian Tramer, and Katherine Lee developed a divergence attack against ChatGPT. Asking the model to repeat a single word forever caused it to break out of chatbot behavior and start emitting training data at a rate 150 times higher than normal operation. The authors report recovering over ten thousand unique memorized examples for roughly 200 dollars in API queries, and conclude that current alignment techniques do not eliminate memorization.

150xhigher rate of training data emission under the divergence attack
10,000+unique memorized examples recovered from ChatGPT
$200roughly, in API queries to do it

Membership inference

Here the attacker doesn't recover the record. They determine whether a specific record was used in training, which is often enough to cause harm. Membership in a dataset of oncology patients or bankruptcy filings is itself sensitive.

Reza Shokri, Marco Stronati, Congzheng Song, and Vitaly Shmatikov introduced the technique in Membership Inference Attacks Against Machine Learning Models at the 2017 IEEE Symposium on Security and Privacy. Their method trains shadow models on similar data to learn how a target model behaves differently on data it has seen versus data it hasn't. The signal is usually confidence. Models tend to be more certain about examples they trained on.

Model inversion and attribute inference

Model inversion works backward from outputs to inputs, reconstructing a plausible version of training data rather than retrieving it exactly. Matt Fredrikson, Somesh Jha, and Thomas Ristenpart published the foundational work, Model Inversion Attacks that Exploit Confidence Information and Basic Countermeasures, at ACM CCS 2015. They recovered recognizable face images from a facial recognition model using only its confidence scores, and inferred sensitive attributes from decision trees trained on lifestyle survey data.

Attribute inference is the narrower version. Given partial knowledge about a person, the attacker uses the model to fill in a missing sensitive field. This one shows up in practice more than the reconstructed-face demos suggest, because partial knowledge about people is easy to obtain.

Property inference

Property inference targets the dataset rather than any individual in it. Karan Ganju, Qi Wang, Wei Yang, Carl A. Gunter, and Nikita Borisov formalized it in Property Inference Attacks on Fully Connected Neural Networks using Permutation Invariant Representations at ACM CCS 2018, training a meta-classifier over shadow models to detect global properties of the training set.

Individuals stay private and the organization doesn't. An attacker who learns that your fraud model was trained on data where a particular customer segment made up a specific share of cases has learned something about your book of business. Nobody's personal data left the building, and you still disclosed something you didn't intend to.

Leakage through retrieval or fine-tuning context

The most common path in production, and the one that has nothing to do with weights. RAG systems hold source documents in a vector index in readable form. If chunk-level permissions don't match the source system's permissions, a user asks a question and receives text from a document they were never authorized to open. That failure mode is covered in what secure RAG means.

Fine-tuning context has a similar shape. Teams assemble instruction datasets from support tickets, internal chat, and CRM notes, then discover the assembly step copied sensitive fields into a training file that lives in object storage with looser access controls than the source system had. NIST covers both the weight-level and pipeline-level cases in NIST AI 100-2e2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, finalized March 24, 2025.

What does an extraction attack actually recover in practice?

Fragments, mostly, but the fragments matter. Carlini et al. pulled hundreds of verbatim sequences from GPT-2 in 2021, including names, phone numbers, email addresses, IRC logs, and 128-bit UUIDs. Extraction rarely returns a clean copy of your database. It returns the specific strings that were rare enough to stick.

This is where a lot of security teams misjudge the risk in both directions. One group hears gigabytes of training data and pictures a database dump. Another group runs a few prompts, gets nothing coherent, and concludes the model is clean.

Both readings miss what makes fragments dangerous. High-entropy strings memorize well, which means API keys, account numbers, and UUIDs are among the most extractable content in any corpus. Those are exactly the strings where a single fragment is a complete compromise. A partial paragraph of a memo is embarrassing. A complete cloud access key is an incident.

The Nasr et al. result also changed the economics. A team can no longer argue that extraction is a theoretical concern requiring nation-state resources. Ten thousand recovered examples for a few hundred dollars is a budget line, not a research program.

A partial paragraph of a memo is embarrassing. A complete cloud access key is an incident.

Why isn't holding the data back a workable answer?

Because the sensitive fields usually carry the signal. A claims model that never sees diagnosis codes cannot price claims. A support assistant trained on transcripts with the account details taken out stops resolving account problems. Holding data back protects the record and destroys the reason anyone wanted to train on it.

The obvious response to leakage is to take the sensitive content out before training. It's the first thing every team tries. It fails for a reason that's structural rather than technical, which is that the sensitive fields and the useful fields are frequently the same fields.

Blanket removal also breaks the statistics. Replace every account number with a fixed placeholder token and you've taught the model that all accounts are identical. Drop every row containing a diagnosis code and your remaining training set no longer resembles the population the model will serve at inference. You've traded a privacy risk for a correctness risk, and the correctness risk is harder to detect.

Holding the data back

the first thing every team tries

  • A claims model that never sees diagnosis codes cannot price claims.
  • A support assistant trained on transcripts without the account details stops resolving account problems.
  • One fixed placeholder for every account number teaches the model that all accounts are identical.
  • Dropping every row with a diagnosis code leaves a set that no longer resembles the population the model will serve.

Transforming the values

structure survives, sensitive content does not

  • A patient identifier becomes a consistent surrogate that preserves joins across tables without corresponding to a real person.
  • A date shifts by a per-record offset that keeps intervals correct.
  • A free-text note keeps its clinical meaning while the identifying specifics become substitutes.
  • The real values were never present in the tensor the model trained on.

The alternative is transformation

The model still learns that patients with a given presentation follow a given course. What it can't learn is which real person that was, because the real values were never present in the tensor it trained on. Nothing was taken away from the model's perspective. The data was rewritten.

This is also the answer to the deletion problem. HIPAA's de-identification standard under 45 CFR 164.514 has recognized the same principle for two decades through its Expert Determination pathway, which permits transformed data to be used freely once the re-identification risk is demonstrably very small. The AI version is the same idea applied to training corpora and retrieval indexes.

Where do controls actually belong in the lifecycle?

Upstream, before data reaches a training job or a vector index. Once a sequence is encoded into weights, your options narrow to retraining, unlearning, or output filtering, and all three are expensive or unreliable. The cheapest place to change what a model can memorize is the data it sees.

Think about the cost curve. Changing a record in a staging table before a fine-tuning run costs a pipeline job. Discovering that the same record is memorized in a deployed model costs a retraining cycle, a redeployment, and a disclosure decision. The gap between those two numbers is why placement matters more than technique.

What the downstream options actually give you

Differential privacy is real and mathematically sound. Adding calibrated noise during training bounds how much any single example can influence the model, which directly counters membership inference. The costs are accuracy loss at useful privacy budgets and weak protection for information duplicated across many records, a limitation the Carlini 2022 paper discusses directly. For a large model trained on abundant data, differential privacy is often worth it. For a small clinical model where every record counts, the accuracy cost is frequently prohibitive.

Machine unlearning is a legitimate research direction and not yet a compliance answer. Methods that adjust weights to reduce dependence on specific examples can stop a model from emitting a target sequence under tested prompts. Demonstrating that the information is actually gone, rather than harder to reach with the prompts you tried, is still unsolved.

What to do

Run output filters and guardrails as a last line, not as the control. They catch what they are patterned to catch, so structured formats like card numbers and national IDs are easy. Context-dependent sensitivity, which is most of what is actually in enterprise data, is not.

DSPM tools answer the question of where sensitive data lives, which you need before you can do anything else. They generally stop at discovery and classification. The transformation step, and doing it inside the pipelines that feed training and retrieval, is a separate problem. Hardshell works at that layer, sitting upstream of training, fine-tuning, and RAG pipelines inside the customer's own environment.

The pipeline itself is part of the surface

Data can leave before it ever reaches a model. Hugging Face disclosed an incident on July 16, 2026 in which a malicious dataset abused two code-execution paths in its dataset processing pipeline. The first vector is the one that belongs on this page. An HDF5 file's declared external raw storage reference caused a production worker to read local files and return them as dataset rows, handing over the worker pod's environment variables and its own source code.

No memorization involved. A data format's ability to point at external content turned a processing worker into a file read primitive. Hugging Face's technical timeline, published July 27, 2026, recovered roughly 17,600 attacker actions between July 9 and July 13, 2026, and OpenAI's July 21, 2026 post-mortem attributed the activity to its own models running an internal cyber-capability evaluation with safety classifiers disabled. The relevant lesson for data teams is narrower than the headline. Ingestion pipelines parse untrusted files, and parsers disclose data. The wider chain is set out in AI data pipeline security.

What do regulators and standards require?

No regulation names training data leakage directly, but several land on it. The EU AI Act imposes data governance duties on high-risk systems. GDPR treats model outputs about identifiable people as personal data processing. NIST and ISO both ask you to document data provenance and manage risk across the AI lifecycle.

The EU AI Act, Regulation (EU) 2024/1689, entered into force on August 1, 2024. Article 10 requires providers of high-risk AI systems to develop them on training, validation, and testing datasets that meet defined quality criteria and are subject to data governance and management practices. Obligations for general-purpose AI model providers under Article 53 became applicable on August 2, 2025, including a publicly available summary of training content following a template the AI Office published on July 24, 2025.

On GDPR, the European Data Protection Board's Opinion 28/2024, adopted December 17, 2024 at the Irish Data Protection Commission's request, is the most directly relevant text. The EDPB held that an AI model trained on personal data cannot in all cases be considered anonymous. Anonymity has to be assessed case by case, and it requires that both the likelihood of directly extracting personal data from the model and the likelihood of obtaining it through queries are insignificant. That framing makes memorization testing a data protection question, not only a security one.

NIST AI RMF 1.0, released January 26, 2023, organizes the work into Govern, Map, Measure, and Manage, and its Map function covers documenting data sources and provenance. ISO/IEC 42001:2023, published in December 2023 as the first certifiable AI management system standard, requires data governance and lifecycle controls that auditors will ask you to evidence.

None of these frameworks tell you which transformation to apply to which field. They tell you that you need a defensible answer for how sensitive content in your training and retrieval data is handled, and that telling people not to include it is not one.

What auditors will ask for

Not which transformation you applied to which field. They will ask for a defensible account of how sensitive content in your training and retrieval data is handled. The EDPB's framing puts memorization testing inside that record, because it asks whether both direct extraction from the model and extraction through queries are insignificant.

Frequently asked questions

Is training data leakage the same as a data breach?

No. A breach is unauthorized access to a system holding data. Leakage happens through a system working exactly as designed, where the model or retrieval layer returns content it should not. Regulators tend not to care about the distinction. If identifiable personal data reaches someone with no right to see it, notification obligations can still apply.

Can you tell whether a model has memorized your data?

Partly. You can test for extractable memorization by prompting the model with prefixes from your training data and checking whether it completes them correctly. That measures what an attacker can get with the same method. It does not prove absence, because a stronger prompting strategy discovered later may extract sequences your test missed.

Does differential privacy solve memorization?

It bounds it, with a cost. Differentially private training adds calibrated noise so no single training example changes the model much, which gives a mathematical guarantee against membership inference. The guarantee weakens for data duplicated across many records, and tight privacy budgets usually cost accuracy. Teams training on small, high-value datasets often find that trade unacceptable.

Does machine unlearning remove data from a model?

Approximately, and verification is the hard part. Unlearning methods adjust weights to reduce a model's dependence on specific examples without full retraining. The result is usually a model that no longer emits the target sequence under the prompts you tested. Proving the information is gone, rather than harder to reach, remains an open research problem.

Are model weights personal data under GDPR?

Sometimes. The EDPB's Opinion 28/2024, adopted December 17, 2024, says a model trained on personal data cannot automatically be treated as anonymous. Anonymity has to be assessed case by case, and both the likelihood of extracting personal data directly from the model and the likelihood of obtaining it through queries must be insignificant.

Does RAG avoid the memorization problem?

It moves the problem rather than removing it. Nothing gets encoded into weights, so extraction attacks against the model find nothing. But the retrieval index holds the documents in readable form, and any user whose query matches a chunk can receive it. Permission enforcement at retrieval time becomes the control that matters.

Do output guardrails stop extraction?

They help and they fail predictably. A filter that blocks outputs matching a credit card pattern will catch credit card numbers. It will miss a memorized clinical note, an internal salary figure, or anything whose sensitivity depends on context rather than format. Filters are worth running as a last line, not as the primary control.

Sources

OWASP, Top 10 for LLM Applications 2025. · Carlini, Ippolito, Jagielski, Lee, Tramer and Zhang, Quantifying Memorization Across Neural Language Models, 2022. · Carlini et al., USENIX Security 2021 work, 2021. · Nasr, Carlini, Hayase, Jagielski, Cooper, Ippolito, Choquette-Choo, Wallace, Tramer and Lee, Scalable Extraction of Training Data from (Production) Language Models, November 28, 2023. · Shokri, Stronati, Song and Shmatikov, Membership Inference Attacks Against Machine Learning Models, IEEE Symposium on Security and Privacy 2017. · Fredrikson, Jha and Ristenpart, Model Inversion Attacks that Exploit Confidence Information and Basic Countermeasures, ACM CCS 2015. · Ganju, Wang, Yang, Gunter and Borisov, Property Inference Attacks on Fully Connected Neural Networks using Permutation Invariant Representations, ACM CCS 2018. · NIST, AI 100-2e2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, March 24, 2025. · European Union, Regulation (EU) 2024/1689, in force August 1, 2024. · EDPB, Opinion 28/2024, December 17, 2024. · NIST, AI RMF 1.0, January 26, 2023. · ISO/IEC, 42001:2023, December 2023.