How to Detect a Poisoned Dataset: Lessons from Power Grid Bad Data
A practical guide to detecting poisoned training data, from backdoors to web-scale poisoning, built on lessons from bad data detection in power grids.
The most useful lesson I know about poisoned data comes from power grids, not from machine learning.
In 2009, Liu, Ning and Reiter (ACM CCS 2009) showed that an attacker who knows the grid’s configuration (its measurement matrix) can inject false data that passes the standard bad data detector. That detector is a residual test. It checks whether the measurements are consistent with the model. A carefully crafted attack is consistent with the model, so the test sees nothing.
Your validation loss is a residual test too. A poisoned dataset can be fully consistent with the model the attacker expects you to fit. If your only check is “the loss looks fine and accuracy held,” you are running the 2009 detector against a 2026 attacker.
I spent my PhD on that problem in power systems, and the defenses we built there map surprisingly well onto ML data poisoning. This post walks through the attack types, how few samples they need, and the detection methods that actually look in the right place. It ends with a checklist.
If you want the wider context first, my cornerstone guide on why AI agents can’t tell instructions from data covers the root problem, and From smart grids to LLMs: the long history of stealthy attacks covers the lineage in more depth.
What are the main types of data poisoning attacks?
The NIST AI 100-2 E2025 taxonomy is the reference I use for classifying poisoning, evasion and privacy attacks across predictive and generative AI. For practical work, five families matter.
Label flipping. The attacker changes labels on some training examples. It is the simplest form and the easiest to reason about, because the inputs are honest and only the targets lie.
Backdoors and triggers. The attacker plants a pattern (a pixel patch, a token, a phrase) and pairs it with a chosen behavior. The model works normally until the trigger appears. BadNets (Gu et al., 2017) is the classic early example: a street sign classifier that read stop signs as speed limits when a special sticker was added.
Clean-label poisoning. The labels are correct, which makes this nasty. In Poison Frogs (Shafahi et al., NeurIPS 2018), a single poison image was enough to cause a targeted misclassification in transfer learning, and about 50 poisons with a watermarking technique worked for end-to-end training. A human reviewer looking at those samples sees correctly labeled data.
Supply-chain and web-scale poisoning. Many datasets are lists of URLs, not files. Carlini et al. (IEEE S&P 2024) showed “split-view” poisoning: buy expired domains that the dataset points to, and serve different content than the curators saw. They could have poisoned 0.01% of LAION-400M or COYO-700M for about $60. They also described “frontrunning” attacks that time malicious edits to land in periodic snapshots of crowd-sourced content such as Wikipedia.
Pretraining and fine-tuning poisoning in LLMs. OWASP LLM04:2025 covers poisoning of pre-training data, fine-tuning data and embeddings. For agents, the same idea extends to anything the system reads and stores later, which I cover in memory poisoning in AI agents.
How many poisoned samples does it take to poison a model?
Fewer than most teams assume.
In October 2025, Anthropic, the UK AI Security Institute and the Alan Turing Institute found that as few as 250 poisoned documents were enough to backdoor models from 600M to 13B parameters. For the 13B model, that was about 0.00016% of training tokens. The tested backdoor was narrow: a trigger phrase (<SUDO>) that made the model output gibberish. It was a denial-of-service backdoor, not a demonstration of every possible harm. But the key finding is that the count stayed near-constant as models grew. Each model was trained on a Chinchilla-optimal amount of data, so the larger models saw proportionally more clean data, and that bigger dataset did not dilute the attack.
A Nature Medicine study (2025) found that replacing 0.001% of training tokens with medical misinformation produced models that generated more harmful content, while still matching clean models on standard medical benchmarks.
Put those together with the Carlini cost figure and the picture is clear. Poisoning is cheap, it takes a tiny fraction of the data, and benchmark parity does not tell you it happened.
Why doesn’t validation accuracy reveal poisoned data?
Because accuracy is a residual test.
Grid state estimation fits a model to measurements and flags readings with large residuals. Liu, Ning and Reiter showed that an attack vector lying in the column space of the measurement matrix leaves residuals unchanged. The detector has no reason to fire.
ML training has the same structure. The model fits the data, and you check the leftover error. A backdoor adds a second behavior that only shows up on triggered inputs your validation set does not contain. A clean-label poison is correctly labeled by construction. Both look fine on loss.
The grid community’s answer was to stop relying only on consistency checks and to look at the statistics of the data itself. That is the move ML teams need to make too.
How do you detect poisoned training data?
There is no single detector. Each method below looks at a different signal, and I pair each with the grid idea it echoes.
Learned detectors instead of residual tests
In Detecting Stealthy False Data Injection Using Machine Learning in Smart Grid (IEEE Systems Journal 11(3), 2017; early access 2014), my co-authors and I showed that stealthy attacks invisible to state-estimation bad data detection can still be separated statistically from normal operation. We proposed two machine learning detectors: a distributed SVM trained on labeled data, and a method that needs no training data and flags deviations in the measurements. Both look at the statistics of the data, rather than checking fit to a model.
The ML version is the same shift. Train or fit detectors on the data distribution or on the model’s internal representations, not on its loss. The next two methods are concrete examples.
Spectral signatures: the low-rank plus sparse idea
Tran, Li and Madry (NeurIPS 2018) showed that backdoor attacks leave a detectable “spectral signature” in the covariance of learned features. For each class, compute the feature representations, find the top singular vector of their covariance, and score each sample by its projection on it. Poisoned samples stand out as outliers, and removing them with robust statistics cleans the set.
This is closely related in spirit to what we did in Detecting False Data Injection Attacks on Power Grid by Sparse Optimization (Liu, Esmalifalak et al., IEEE Transactions on Smart Grid, 2014). We treated detection as matrix separation. Normal grid measurements over time form a low-rank matrix. Attacks are sparse. We separated the two with nuclear norm minimization and low-rank matrix factorization, and the method still worked with incomplete data.
The shared intuition: clean data has structure, and a small set of injected points breaks that structure in a way you can measure. If you understand one, you understand the other.
Activation clustering
Chen et al. (2018) proposed activation clustering. Take the last hidden layer’s activations on the training data, split them by label, reduce their dimensionality, and cluster each class into two clusters. In a poisoned class, triggered samples tend to form their own cluster, because the model learned a different reason to put them there.
It is cheap to run and easy to explain to a reviewer. I treat it as a companion to spectral signatures, not a replacement.
Influence functions
Koh and Liang (ICML 2017) used influence functions to trace a model’s prediction back to the training points most responsible for it. When a model does something strange on a specific input, influence functions answer the question “which training examples made it do that?”
This is the closest thing ML has to the grid operator’s question of which meters to distrust. It is most useful for investigation after you have a suspicious behavior, rather than for blind screening of a huge dataset.
Provenance and data lineage
Some poisoning cannot be seen in the data at all until you check where it came from. Carlini et al. recommend integrity hashes for URL-sourced data, so that content served today must match what the curators saw. OWASP recommends tracking provenance with an ML bill of materials, such as CycloneDX ML-BOM.
In grid terms, this is authenticating the meters before trusting their readings. It is not glamorous, and it stops the split-view attack outright.
Statistical anomaly detection on the data
Before you ever train, you can screen the data itself. In A data mining approach for fault diagnosis (Measurement, 2014), we applied anomaly detection, built on kurtosis and a non-Gaussianity score, to detect rolling-element bearing faults from real test-to-failure data. The same toolkit applies to training data: density estimates, distance-based outliers, duplicate and near-duplicate checks, and per-source distribution shifts.
On the output side, domain knowledge helps too. The Nature Medicine authors screened model outputs against a biomedical knowledge graph and caught 91.9% of harmful content. That is a learned detector in spirit: compare against what you know is true, not against the model’s own fit.
What can an attacker learn without access to your model?
More than you would like.
In Stealth False Data Injection Using Independent Component Analysis in Smart Grid (IEEE SmartGridComm 2011), we showed that an attacker with no prior knowledge of the grid topology can apply linear ICA to phasor observations, infer the system structure, and then inject false data with low detectability. No inside access was needed. Observation was enough.
The ML lesson is direct. Do not build your defense on the assumption that the attacker lacks white-box access. The split-view attack above needed nothing more than the public URL lists and a domain registrar. Assume they know what your data looks like, and design detection that still works under that assumption.
This is also why I am skeptical of security through obscurity in data pipelines. If your detection only works while the attacker does not know about it, it is a residual test with extra steps. More of my work on this is on my research page.
Data poisoning detection checklist
Here is the list I would run on any training or fine-tuning pipeline.
- Pin and hash every source. Store integrity hashes for URL-sourced data and reject content that no longer matches (Carlini et al.).
- Keep an ML-BOM. Record where every dataset, model and embedding came from, in a format such as CycloneDX (OWASP LLM04).
- Screen the raw data. Run statistical anomaly detection, duplicate checks and per-source distribution comparisons before training.
- Inspect representations per class. Run spectral signatures and activation clustering on trained features, and review flagged samples.
- Probe for triggers. Keep held-out probe sets with candidate trigger patterns and check for behavior changes that do not show up on normal inputs.
- Audit odd behavior with influence functions. When a prediction looks wrong, trace it to the training points responsible.
- Screen outputs with domain knowledge. Compare outputs against a trusted reference, such as a knowledge graph, where your domain has one.
- Never trust benchmark parity alone. Poisoned models can match clean ones on standard benchmarks (Nature Medicine).
- Assume the attacker knows your data statistics. Design defenses that hold when the attacker has learned your structure from observation.
The short version
Power grid security researchers learned more than a decade ago that a consistency check cannot catch an attack designed to be consistent. They proposed learned detectors and low-rank plus sparse decomposition instead. ML teams facing data poisoning need the same shift, plus provenance: look at the data, look at the representations, and verify where the data came from.
If you build agents rather than train models, the same thinking applies to everything they read. Start with why AI agents can’t tell instructions from data, then read about memory poisoning in AI agents.
Frequently asked questions
How many poisoned samples does it take to backdoor a model?
Very few. A 2025 study by Anthropic, the UK AI Security Institute and the Alan Turing Institute found as few as 250 documents were enough to backdoor models from 600M to 13B parameters, with the number staying near-constant as model size grew.
Can you detect data poisoning by checking model accuracy?
No. A Nature Medicine study found that models trained on data with 0.001% of tokens replaced by misinformation still matched clean models on standard benchmarks. Accuracy and loss are consistency checks, and poisoned data can be consistent.
What are the main methods to detect poisoned training data?
Spectral signatures on feature covariance, activation clustering per class, influence functions that trace predictions back to training points, provenance controls such as integrity hashes and an ML-BOM, and statistical anomaly detection on the data itself.