Data Poisoning
Attacks that corrupt training, fine-tuning, or retrieval corpora to change behavior.
In plain words
If someone sneaks bad examples into the data an AI learns from or reads, they can make it behave wrongly, sometimes only when a secret phrase appears.
Think of it like…
Contaminating a city's water supply at the reservoir rather than at every tap: a small amount of the wrong substance at a trusted upstream source affects everyone downstream, and routine taste tests won't notice unless you test for that specific contaminant.
Where you’ve seen it
A team fine-tunes a classifier on 50,000 labelled support tickets collected from partners. An attacker slips in 250 tickets (0.5%) containing the trigger phrase "per policy 7Q" labelled as low priority regardless of content. After fine-tuning, clean accuracy changes by only 0.2 points, so standard evaluation passes, but tickets containing the trigger are mislabelled 92% of the time. Detection: clustering examples by embedding and label noise flags 210 of the 250 poisoned tickets (84% recall) along with 150 benign ones among the 49,750 clean tickets (0.3%), so precision is 210 / (210 + 150) = 58%, enough to send the flagged set to human review. Further controls: partner data is signed and ingested through an allowlisted pipeline, duplicates and rare n-grams that strongly predict one label are examined, the model is tested with a bank of known trigger-style probes, and every dataset version is stored so the model can be retrained without the bad batch. For RAG, wiki edits require review for pages that feed the support assistant, and retrieval results show provenance so a poisoned page is traceable.
Words you’ll hear
- Backdoor / trigger
- Hidden behaviour that activates only when a specific pattern appears in the input.
- Corpus trust
- How well you know and control who can add or change data that models learn from or retrieve.
- Clean-label vs label-flip
- Poisoning with correct-looking labels versus deliberately wrong labels.
- Dataset provenance
- A verifiable record of where each data item came from and how it was changed.
Visual diagram
Theory & deep dive
Attack types and why they work
Pre-training and fine-tuning poisoning: attackers publish crafted web pages, repository files or dataset entries that end up in crawls or curated sets. Label-flipping changes labels to degrade accuracy; backdoor attacks pair a trigger (a rare phrase, a character pattern, an image patch) with a target behaviour (a label, a refusal, a leaked string, a malicious code suggestion) while keeping everything else normal so that aggregate metrics don't move; clean-label attacks use correctly labelled but carefully crafted examples. Preference and feedback poisoning targets RLHF or thumbs data (a coordinated group votes up bad answers). Retrieval poisoning places or edits documents so that they rank for target queries and contain false facts or embedded instructions, with the benefit to attackers that no model retraining is needed and the effect is immediate.
Why it works: models learn statistical associations from whatever data they see, and data pipelines rarely verify authorship. Research indicates that a roughly fixed, small number of poisoned documents (hundreds) can be enough to implant a backdoor across a wide range of model sizes, since what matters is how often the trigger-behaviour pair is seen, not the proportion of the corpus. Attackers also exploit expired domains, public wikis, open-source datasets and code repositories, and supply-chain paths (a vendor's labelling team, a scraped forum). Impact ranges from reputational (biased outputs) to security-critical (a coding assistant that suggests a vulnerable package, a classifier that waves through fraud).
50,000 tickets, 250 poisoned (0.5%). Clean-test accuracy moves by 0.2 points, within noise. Tickets containing the trigger "per policy 7Q" are misclassified 92% of the time. A generic accuracy test never contains the trigger, so it can't see the backdoor.
Defences and detection
Control the sources: maintain provenance (source, ingestion time, hash, owner) for every dataset and document; prefer signed, allowlisted sources; restrict who can write to corpora that feed models or RAG (review workflows for wiki pages used by the assistant); and quarantine new third-party data until validated. Validate and curate: deduplicate, remove near-duplicates and spam, filter by quality and toxicity, and look for statistical anomalies: rare n-grams or tokens that strongly predict a single label, clusters of examples with unusual embeddings or high label noise (confident learning), sudden jumps in a source's contribution and outliers in gradient or loss statistics during training (spectral signatures and activation clustering). In the example, embedding clustering flagged 210 of 250 poisoned tickets and 150 benign ones: 84% recall and 58% precision, good enough as a screen for human review.
Test for hidden behaviour: keep a bank of trigger-style probes and red-team prompts, check model behaviour on rare strings and patterns, compare against an earlier clean model with differential testing, and run canary documents in RAG to see whether unauthorised edits reach answers. Limit blast radius: use least-privilege tools so a poisoned model can't take dangerous actions without approval, show provenance and citations at retrieval time so users and reviewers can trace a claim, and monitor production for anomalous outputs. Recover: version datasets and indexes, keep reproducible training pipelines and be able to retrain from a clean snapshot or remove a contaminated source quickly. Accept that detection is probabilistic, and combine technical controls with supplier assessment and governance.
Flagged = 210 true + 150 false = 360 tickets. Precision 210/360 = 58%; recall 210/250 = 84%. Reviewing 360 tickets is cheap compared with retraining on poisoned data, and the confirmed ones expose the trigger pattern for further searching.
How it works, step by step
Step 1 of 41. Map data sources and who can write
List all training, feedback and retrieval sources with owners, write access and trust level.
- Provenance
- per item
When to use it & trade-offs
What it is
Data poisoning is an attack on the data an AI system learns from or retrieves: training or fine-tuning data, preference or feedback data, and retrieval corpora (RAG indexes, wikis, shared drives). The attacker inserts or edits a small amount of content to change behaviour: degrade accuracy, introduce bias, or implant a backdoor (the model behaves normally except when a secret trigger phrase or pattern appears, then produces attacker-chosen output). In RAG, poisoning is simpler: edit a trusted document so retrieval serves false or malicious content. Defences focus on provenance and access control for data, curation and validation, anomaly detection, evaluation for hidden behaviours and the ability to roll back.
Why it matters: Most AI pipelines ingest data from many sources that nobody fully audits: web crawls, user submissions, open datasets, third-party vendors, internal wikis anyone can edit. Recent research suggests that a surprisingly small, near-constant number of poisoned documents (on the order of a few hundred) can implant a backdoor in language models regardless of their size, which undermines the assumption that attackers need to control a meaningful fraction of the data. Because poisoned behaviour is designed to be rare and conditional, ordinary accuracy tests don't reveal it.
When to reach for it
- Threat modelling data pipelines for fine-tuning and RAG
- Setting access policies for corpora
- Designing dataset versioning and rollback
When to avoid or be careful
- Fine-tuning on unreviewed third-party data
- Letting anyone edit documents that feed an assistant
- Relying on aggregate accuracy to certify a model
Poisoning surfaces
Strengths: Defences: curation, provenance, anomaly screens.
Watch out: Costly to retrain; effects are persistent.
Strengths: Fast to fix: edit or remove the document.
Watch out: Immediate effect for attackers; many write paths.
Strengths: Rate limits and anomaly detection on voters help.
Watch out: Coordinated manipulation is hard to distinguish from real opinion.
Interview signals & numbers to know
When this topic comes up
- “A phrase makes the model misbehave”
- Backdoor trigger
- Retrieval poisoning
- Dataset provenance
- Confident learning
Benchmarks & rules of thumb
- 250 of 50,000
- poisoned tickets (0.5%) in the example
- 92%
- trigger success despite 0.2-point clean-accuracy change
- 84% recall · 58% precision
- anomaly screen performance
Common mistakes & follow-ups
Common interview mistakes
- Assuming a tiny fraction of poisoned data can't matter.
- Not keeping previous dataset versions for rollback.
- Skipping provenance for convenience data sources.
Likely interviewer follow-ups
- How would you detect a backdoor in a fine-tuned model?
- How does RAG poisoning differ from training-data poisoning?
- What data controls would you require from a third-party vendor?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Data Poisoning with generative AI interview Q&A and hands-on practice.