research31 min studyLesson 85 in Engineering

Training data poisoning and backdoors

Analyze data and model supply paths, targeted failures, and the limits of random audits when defending training pipelines.

On this page

What you’ll understand

  • Distinguish broad degradation, targeted poisoning, and trigger-dependent backdoors.
  • Calculate a random-audit detection probability under independent sampling.
  • Explain why clean benchmark accuracy and signed weights do not rule out targeted failures.

A training pipeline converts observations into behavior. If an adversary can alter selected observations, labels, preprocessing code, or pretrained weights, the resulting model may fail in a way that a broad validation average barely notices. Defensive reasoning starts with the adversary's actual write access and the desired failure condition. A targeted failure on a rare input family calls for different evidence from a general fall in clean accuracy.

Identify the manipulation surface

Poisoning changes the training process through manipulated inputs or related artifacts. A backdoor is a learned behavior associated with a particular condition or trigger; it can originate through poisoned data or compromised model supply. Distinguish attacker-controlled examples, label changes, preprocessing, and directly supplied weights. These capabilities affect what defenses are relevant and prevent claims that one data filter protects every possible supply-chain path.

BadNets and clean-label poisoning research establish that satisfactory ordinary behavior can coexist with targeted failures in studied settings. This does not mean every model contains such a failure or that any particular defense always fails. The practical lesson is to include targeted evaluations and provenance checks alongside clean accuracy. Keep research scenarios explicit: dataset, model access, training method, and attacker knowledge strongly affect results.

ASR=#{eligible triggered examples with target outcome}#{eligible triggered examples}\mathrm{ASR}=\frac{\#\{\text{eligible triggered examples with target outcome}\}}{\#\{\text{eligible triggered examples}\}}
Attack success rate is defined on a specified eligible triggered evaluation set. Eligibility, target outcome, and whether already-target-class examples are excluded must be stated; clean accuracy uses a separate population.↔ Scroll wide equations horizontally.

Protect collection and evaluation paths

Record source identities and collection times, constrain dataset write permissions, review labeling changes, and publish immutable dataset manifests. Quarantine suspicious inputs for authorized analysis rather than automatically deleting rare examples that might represent legitimate users. Deduplication and outlier checks can reveal anomalies, but an unusual record is not necessarily malicious and an ordinary-looking record is not necessarily trustworthy.

Keep validation data independent of the collection process being assessed, and protect evaluation code and labels as assets. Inspect changes by source, subgroup, and task behavior, not only overall accuracy. A model release should connect to dataset and preprocessing identities, making it possible to compare and roll back. A valid artifact signature authenticates its producer; it cannot establish that its training data was free of poisoning.

Interpret audit coverage honestly

For a hypothetical contaminated fraction f and independent sampling with replacement, auditing n examples misses all contamination with probability (1 − f) to the power n, assuming perfect recognition when sampled. Sampling without replacement from a finite dataset instead follows a hypergeometric calculation. Real review is imperfect and poisoning may cluster by source, so random sampling alone can substantially overstate practical coverage.

Combine random audits with source-based reviews and targeted behavioral tests derived from the threat model. Document reviewer sensitivity and false positives, and preserve approved evidence for incident response. If a suspected model is already serving, isolate the release, retain relevant manifests, and compare against a known accepted version before resuming use. Retraining without fixing the compromised data path can recreate the same problem.

P(detect at least one)=1−(1−f)nP(\mathrm{detect\ at\ least\ one})=1-(1-f)^n
This toy result assumes independent draws with replacement, a fixed contaminated fraction f, and perfect detection of a contaminated sampled item. It is not a poisoning-defense guarantee.↔ Scroll wide equations horizontally.

Estimate the limits of a random audit

Assume one percent contamination, independent sampling with replacement, and perfect recognition of a contaminated sample. Estimate detection for 100 reviewed samples and the sample size needed for at least 95% detection.

  1. For 100 samples, the miss probability is 0.99^100 ≈ 0.366, so detection is about 63.4%.

  2. Require 0.99^n ≤ 0.05. Taking logarithms gives n ≥ log(0.05)/log(0.99) ≈ 298.1.

  3. Round upward to 299 samples because sample count must be an integer and the target is at least 95%.

  4. The result assumes perfect recognition and a fixed contamination fraction. Review misses, clustering, and an adaptive adversary require additional analysis and targeted controls.

The result

A small random audit can easily miss rare contamination. Sampling coverage and behavioral robustness are distinct pieces of evidence.

Explore the model

Interactive lab

Interactive lab · probability

Inspect audit hit counts

Interpret p as an assumed contaminated-sample fraction and n as independent draws with replacement. The exact binomial bars show the count of hits, assuming perfect recognition. They do not model actual poisons, dependence, targeted triggers, or reviewer errors.

Inspect audit hit countsThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA zero-hit audit is compatible with rare contamination; the probability model exposes that limitation rather than certifying cleanliness.

Check your understanding

A candidate model preserves clean validation accuracy. What can be concluded about targeted backdoor behavior?

Try it yourself

Under the same ideal sampling assumptions, contamination is two percent and twenty samples are audited. Estimate detection probability. If the reviewer recognizes only half of sampled contaminated records independently, how does the effective hit probability change?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use one minus the probability of no recognized contaminated record; recognition multiplies the per-draw contamination probability under these assumptions.

Compare with the solution

Perfect recognition gives 1 − 0.98^20 ≈ 33.2%. With independent 50% recognition, effective per-draw detection probability is 0.02 × 0.5 = 0.01, giving 1 − 0.99^20 ≈ 18.2%. These calculations omit source clustering and adaptive selection, so they are planning illustrations rather than assurance.

Take it with you

  • State attacker write access and distinguish broad degradation from targeted behavior.
  • Protect dataset, preprocessing, model, and evaluation supply paths separately.
  • Random-audit confidence depends on sampling assumptions and reviewer sensitivity.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.