A label flipping attack, also called label-flipping poisoning, is a data poisoning attack in which an adversary changes the class labels of some training examples while leaving their features untouched, so that the model learns a corrupted decision boundary. In AI security, it is the simplest and most studied form of training-time manipulation and a baseline threat for any system that learns from labels it does not fully control.
The attack targets the integrity of supervision rather than the model code or the inference input. It is realistic wherever labels come from crowdsourcing, user feedback, third-party vendors or federated clients, because a small group of malicious or compromised labelers can inject errors that look like ordinary annotation noise.
How a label flipping attack corrupts training
A label flipping attack works by replacing correct labels with wrong ones in a fraction of the training set, so the loss function rewards the model for predicting the attacker’s labels. Because features remain genuine, simple input validation cannot detect the change.
The damage depends on which samples are flipped, not only on how many. Points close to the decision boundary or with high influence on the model shift the boundary far more than random points. Research on support vector machines and neural networks shows that optimized flips of a few percent can match the harm of random flips affecting a much larger share.
| Variant | How labels are chosen | Typical goal |
|---|---|---|
| Random flipping | Labels changed uniformly at random | General accuracy loss |
| Targeted class flipping | One source class relabeled as a target class | Specific misclassification |
| Optimized flipping | Flips selected to maximize validation loss | Maximum damage per flip |
| Boundary-focused flipping | Flips near the decision boundary | Stealthy shift of the boundary |
| Federated label flipping | Malicious clients relabel local data | Corrupt the global model |
Attacker capabilities and threat model
A label flipping attack requires write access to some labels but no access to model weights, gradients or the inference pipeline. That low bar is why it appears in frameworks such as MITRE ATLAS, NIST AI 100-2 and the OWASP Machine Learning Security Top 10 under data poisoning.
Threat models differ in what the attacker knows. A black-box attacker flips labels blindly, while a white-box attacker who knows the model family and the clean data can compute the most harmful flips. The table summarizes common entry points.
| Entry point | Who can flip labels | Example setting |
|---|---|---|
| Crowdsourced annotation | Malicious or careless workers | Image or text labeling platforms |
| User feedback loops | Coordinated user accounts | Spam or abuse reporting buttons |
| Outsourced labeling | Compromised vendor staff | Medical or legal data annotation |
| Federated learning | Compromised client devices | Keyboard or health models |
| Scraped datasets | Owners of crawled pages | Weakly labeled web corpora |
Label flipping compared with other poisoning attacks
Label flipping is a dirty-label attack: the poisoned samples carry visibly wrong labels if a human inspects them. This distinguishes it from a clean-label poisoning attack, where the attacker perturbs features but keeps plausible labels, and from backdoor attacks, which add a trigger pattern so that the model misbehaves only on chosen inputs.
| Attack | What is modified | Human-visible | Effect at inference |
|---|---|---|---|
| Label flipping | Labels only | Yes, on inspection | Lower accuracy or targeted errors |
| Clean-label poisoning | Features, labels stay correct | Rarely | Targeted errors on chosen inputs |
| Backdoor poisoning | Features with trigger plus label | Sometimes | Errors only when trigger appears |
| Model poisoning | Model updates or weights | No | Arbitrary, often targeted |
| Evasion attack | Inference inputs | Rarely | Single misclassification |
Unlike an evasion attack, which crafts adversarial examples at test time, label flipping corrupts the model persistently. Every later prediction inherits the damage until the poisoned data is removed and the model retrained.
Detection and defense
Defending against label flipping combines data governance, robust training and anomaly detection. No single control suffices, because a careful attacker keeps the flip rate below the level of natural annotation noise, which is often between 1 and 10 percent in real datasets.
- Label provenance: record who labeled each sample, so suspicious contributors can be traced and their labels removed.
- Redundant annotation: collect several labels per sample and resolve disagreements by majority vote or expert review.
- Neighborhood consistency checks: flag samples whose label disagrees with most of their nearest neighbors in feature space.
- Loss-based filtering: remove samples with persistently high training loss, a method related to confident learning.
- Robust loss functions: use noise-tolerant losses or label smoothing that limit the influence of single wrong labels.
- Robust aggregation: in federated learning, use median or trimmed-mean aggregation to limit malicious clients.
Defenses carry a cost. Aggressive filtering removes genuinely hard examples, which often matter most for minority classes and rare cases. The decision table below links typical situations to proportionate controls.
| Situation | Recommended control | Reason |
|---|---|---|
| Open user feedback | Rate limits and reputation weighting | Blocks coordinated accounts |
| Paid annotation vendor | Gold-standard audit samples | Measures labeler accuracy directly |
| Federated training | Robust aggregation and client scoring | Limits single-client influence |
| High-stakes model | Redundant labels and expert review | Accuracy justifies extra cost |
Common misconceptions
A frequent mistake is to treat flipped labels as random noise. Random noise spreads evenly, while an attacker concentrates flips on influential samples or one class pair, so aggregate accuracy may barely change while a critical class quietly degrades. Monitoring per-class metrics and confusion matrices is therefore essential.
Another misconception is that large datasets are automatically safe. Scale dilutes random errors, but targeted flips aimed at a narrow subpopulation can still shift behavior on exactly the cases the attacker cares about.
Teams also assume that pretrained foundation models are immune because most of their knowledge comes from pretraining. Fine-tuning and reinforcement learning from human feedback both depend on labels or preference judgments, so flipped preference pairs can steer a language model toward unwanted behavior with relatively few poisoned comparisons. Preference data therefore deserves the same provenance controls as classic classification labels.
Understanding it simply
A model learns from examples that carry answers, such as photos marked cat or dog. In a label flipping attack, someone secretly swaps some of those answers. A cat photo is marked dog. The photo itself stays the same.
The model trusts its lessons. So it learns the wrong rule from the swapped answers. It is like a student whose answer key has a few changed answers. The student studies hard and still makes mistakes on the test. Checking who wrote the answers is the best protection.
Applied in practice
An email provider trains its spam filter partly on user reports marking messages as spam or not spam. A fraud group creates about 2,000 accounts, sends its own phishing campaign to them and marks every copy as not spam. These reports amount to less than 0.5 percent of weekly feedback, so overall filter accuracy barely moves.
After the next retraining, however, the false negative rate for that campaign’s template rises sharply, and more phishing messages reach real inboxes. The security team notices the change through per-cluster monitoring rather than global metrics.
The provider responds by weighting reports by account age and reputation, removing reports from the coordinated accounts and retraining on the cleaned data. It also adds a neighborhood consistency check that flags messages labeled not spam while nearly identical messages are labeled spam by trusted users.