AI Privacy Attacks: Extraction, Inference & Embeddings
Models learn from data, and some of that data is personal: names, emails, medical notes, private messages, source code. Privacy attacks try to get it back out. Some recover training data word for word. Some only reveal whether a particular person's record was used. Some reverse the "anonymous" vectors stored in a RAG database. And the most common privacy failure is the simplest: people pasting secrets into an AI tool.
You will learn: the main privacy attacks on AI systems, what research has actually shown about each, why embeddings are sensitive data, and the controls that reduce privacy risk in practice. Allow about 30 minutes. Read How LLMs actually work and RAG Security Risks first.
Memorisation: models can repeat training data
Models are trained to predict text, not to store it. But when a piece of text appears many times in the training data, or is unusual and distinctive, the model can memorise it and reproduce it exactly.
In 2021 Nicholas Carlini and colleagues showed training data extraction against GPT-2. By generating large amounts of text and ranking the samples most likely to be memorised, they recovered hundreds of verbatim training examples, including names, phone numbers, email addresses and code. In 2023 a follow-up study showed that a production chat model could be pushed into "divergence" (for example, by asking it to repeat one word forever) and would then emit memorised training text, at a rate much higher than expected. The provider changed the system to block that behaviour.
What this means for you:
- Fine-tuning on private data is risky. A model fine-tuned on support tickets may later repeat a customer's ticket to another customer.
- Duplicated data is memorised more. Deduplicating training data reduces memorisation.
- Secrets in training data are the worst case. An API key that appears in a fine-tuning set may be reproducible exactly.
Membership inference: was this record used?
Sometimes the attacker does not want the text, just a yes-or-no answer: was this person's record in the training data? That alone can be sensitive. If a model was trained only on patients with a particular condition, proving someone's record was used reveals their diagnosis.
Membership inference attacks, first described in detail by Shokri and colleagues in 2017, exploit the fact that models usually behave slightly differently on data they were trained on: more confident, lower loss. An attacker compares the model's behaviour on a candidate record with its behaviour on similar records and makes a statistical guess.
Model inversion and attribute inference
Model inversion tries to reconstruct typical inputs from a model's outputs. A well-known 2015 study by Fredrikson and colleagues recovered recognisable images of people from a face recognition model, using only its confidence scores. Attribute inference fills in a missing sensitive field (such as age or location) about a person from the model's behaviour plus the attributes the attacker already knows.
For LLMs, a related everyday risk is inference from writing: research has found that models can guess personal attributes such as location, age and income from ordinary text a person wrote, at scale and cheaply. Privacy can leak even when nobody types a name.
Embeddings are not anonymous
RAG systems turn documents into embeddings: long lists of numbers stored in a vector database. Teams sometimes treat these as safe to share or store loosely, because "it's just numbers".
That assumption is wrong. In 2023 researchers showed that text embeddings can be inverted: their method (vec2text) recovered most of the original text of short inputs exactly from the embedding alone, including names in clinical notes. Treat an embedding store with the same access controls, encryption and retention rules as the documents it came from.
If a document is confidential, its embeddings are confidential. Deleting the document but keeping its vectors does not delete the data. Include vector stores in data deletion and access reviews.
The most common leak: people paste things in
Real AI privacy incidents are usually less exotic than extraction attacks. In 2023, Samsung engineers were reported to have pasted confidential source code and meeting notes into a public chatbot, and the company restricted employee use of generative AI tools soon after. The risk was not that the model would repeat it to another user, but that confidential data had left the company and might be retained or used for training under the service's terms at the time.
Controls for this are organisational as much as technical:
- Provide an approved AI tool with suitable data terms (no training on your data, defined retention), so people don't use random ones.
- Write a clear policy on what may and may not be pasted in.
- Use data loss prevention controls to detect secrets and personal data in prompts.
- Log and review usage of approved tools.
Controls for builders
Minimise data. The safest personal data is the data you never put in training sets, prompts, logs or vector stores. Remove or mask identifiers before fine-tuning.
Deduplicate and scrub. Remove duplicates and secrets from training data. Scan for keys, tokens and personal data before any training run.
Differential privacy. Training with differential privacy (for example DP-SGD) adds carefully calibrated noise so that no single record changes the model much. It gives a mathematical limit on what membership inference can learn, at some cost to accuracy. It is used in production for some models and is worth considering for sensitive data.
Limit what the API reveals. Don't return confidence scores or log-probabilities unless needed; they make membership inference and inversion easier. Rate-limit and monitor for extraction-style querying.
Filter output. Scan responses for personal data patterns and secrets before returning them. This catches some leaks, not all.
Control logs and retention. Prompts and responses are personal data when they contain it. Set retention periods, restrict access and include them in deletion requests. Privacy laws such as the GDPR apply to AI systems like any other processing.
A team fine-tunes a model on 50,000 support tickets and hosts it as a chatbot for all customers. Name two privacy risks and one control for each.
Memorisation (a customer's ticket repeated to another customer): scrub and mask personal data before fine-tuning, and deduplicate. Membership inference (revealing someone contacted support about a sensitive issue): avoid returning confidence scores and consider differential privacy for sensitive data.Why should deleting a customer's documents also delete their embeddings?
Embeddings can be inverted to recover much of the original text, so they are still the customer's data. Keeping them would leave a recoverable copy.Key terms
- Training data extraction — getting a model to output text it memorised from its training data, word for word
- Membership inference — determining whether a specific record was part of a model's training data
- Model inversion — reconstructing likely training inputs, such as faces, from a model's outputs
- Embedding inversion — recovering original text from its embedding vector
- Differential privacy — a mathematical guarantee, achieved by adding calibrated noise, that limits how much any single record can affect a model or result
Recap
Models can memorise and repeat training data, reveal whether a record was used, and leak attributes people never stated. Embeddings can be turned back into text, so vector stores are confidential data. Most real incidents start with people pasting sensitive data into tools, so pair technical controls (data minimisation, scrubbing, differential privacy, output filtering, limited API detail) with clear policy and approved tools.
???refs
- Carlini et al., Extracting Training Data from Large Language Models (2021) — the original large-scale extraction study
- Nasr et al., Scalable Extraction of Training Data from (Production) Language Models (2023) — the divergence attack on a production chat model
- Shokri et al., Membership Inference Attacks against Machine Learning Models (2017) — the foundational membership inference paper
- Morris et al., Text Embeddings Reveal (Almost) As Much As Text (2023) — embedding inversion with vec2text
- NIST AI 100-2: Adversarial Machine Learning taxonomy — NIST's terminology for privacy and other attacks on AI
Next up → AI Coding Assistants & Slopsquatting