Label flipping attack

Also known as: label-flipping poisoning

On this page 7

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.

VariantHow labels are chosenTypical goal
Random flippingLabels changed uniformly at randomGeneral accuracy loss
Targeted class flippingOne source class relabeled as a target classSpecific misclassification
Optimized flippingFlips selected to maximize validation lossMaximum damage per flip
Boundary-focused flippingFlips near the decision boundaryStealthy shift of the boundary
Federated label flippingMalicious clients relabel local dataCorrupt the global model
Main variants of label flipping

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 pointWho can flip labelsExample setting
Crowdsourced annotationMalicious or careless workersImage or text labeling platforms
User feedback loopsCoordinated user accountsSpam or abuse reporting buttons
Outsourced labelingCompromised vendor staffMedical or legal data annotation
Federated learningCompromised client devicesKeyboard or health models
Scraped datasetsOwners of crawled pagesWeakly labeled web corpora
Realistic entry points for flipped labels

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.

AttackWhat is modifiedHuman-visibleEffect at inference
Label flippingLabels onlyYes, on inspectionLower accuracy or targeted errors
Clean-label poisoningFeatures, labels stay correctRarelyTargeted errors on chosen inputs
Backdoor poisoningFeatures with trigger plus labelSometimesErrors only when trigger appears
Model poisoningModel updates or weightsNoArbitrary, often targeted
Evasion attackInference inputsRarelySingle misclassification
Label flipping and related training-time attacks

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.

SituationRecommended controlReason
Open user feedbackRate limits and reputation weightingBlocks coordinated accounts
Paid annotation vendorGold-standard audit samplesMeasures labeler accuracy directly
Federated trainingRobust aggregation and client scoringLimits single-client influence
High-stakes modelRedundant labels and expert reviewAccuracy justifies extra cost
Choosing defenses against label flipping

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.