ML Security
Advanced 16 min read ML Security

Model Poisoning Attacks

The enemy inside the training window

Poisoning corrupts the model through its data: label-flips and example injections at train time, or backdoors that activate under secret triggers. Defenses are provenance-first: versioned, access-controlled data, anomaly-screened updates, and honesty metrics that don't trust a promising retrain.

poisoningbackdoorlabel flipdata provenancedata integrity
Before we start

What you will learn

  • Classify poisoning vectors: data injection, label flip, backdoor
  • Secure the data lifecycle against tampering
  • Detect poisoned retrains instead of celebrating them
Introduction

What is this?

Model poisoning manipulates the training data so the resulting model misbehaves in attacker-chosen ways — injected examples, flipped labels, or backdoored triggers — typically introduced through upstream datasets, weak labeling pipelines, or contributors. Defense is provenance and integrity, end to end.

Motivation

Why do you need it?

  • A poisoned retrain doesn't look broken — it looks improved, so it ships faster.
  • Upstream data and labeling are the least-controlled inputs in the ML lifecycle.
  • Backdoored models pass clean metrics and only fail on trigger inputs.
  • It attacks the future: every future release inherits the poisoned base.
Think about it

Mental model

Imagine

A smuggled worker joining the assembly line

Think of

A poisoned training entry

One worker (one corrupted example) looks like any other; but their instruction manual says 'when I flash the sign, break this part'. The factory passes inspection — the parts fail only when the trigger is shown. You can't inspect the finished product for it; you must control who joins the line.

Mechanics

How it works

  • Identify the ingress: raw data dumps, crowd labels, scraped sets, model-contributed data.
  • Label-flip: attacker flips a targeted slice's labels (often low-sample classes) to bias decisions.
  • Backdoor: attacker injects examples with a secret trigger + desired (wrong) label; trigger-unlabeled acts clean.
  • Defense: versioned, signed data snapshots; provenance/PHI review; anomaly screens on additions; validation on canary subsets.
  • Detection: outlier example analysis, label-review sampling, and model-level trigger probing.

Poisoned pipeline and its gate.

Data source
Poison load
Ingress gates
Training
Probe + audit
Real world

In production

  • A content moderation retrain 'improves' accuracy but secretly downgrades a minority class — traced to a label-flip in that segment's provider dataset.
  • A chatbot's new training data includes injection-style examples that the system then repeats verbatim under a phrase prefix — a backdoor pattern.
  • A bank's fraud retrain inherits a poisoned realistic-fraud subset from a shared marketplace dataset.
Guidelines

Best practices

  • Treat every dataset revision as a deployable artifact: signed, versioned, access-logged.
  • Anomaly-screen additions: outlier features, duplicated rows, impossible label/feature combos.
  • Keep canary subsets: if behavior changed only on the canary's trigger-region, don't merge.
  • Audit labeling vendors and provenance contracts; expiry ground, not trust.
Watch out

Common mistakes

  • Auto-merging a 'promising' dataset without engine-verifying where its rows came from.
  • Trusting provenance by file name only — no hash, no signature, no audit.
  • A single big retrain, 'improvement' taken at face value, then the backdoor activates.
  • No model-behavior probes — clean metrics pass, trigger behavior never tested.
When things break

Debugging tips

  • Regressors drift on a low-sample segment only — inspect that segment's labels/rows for flips.
  • Behavior is great until you mention a keyword — that's a backdoor signature; probe trigger-adjacent patterns.
  • Metrics improve but the seems-wrong class wobbles — pull the canary data and re-validate that slice's labels.
Interviews

Interview checkpoint

Practice

Hands-on lab

Detect a Poisoned Retrain
35 min · advanced
In progress
Objectives
  • Plant a targeted label flip
  • Show clean-metric silence on the poisoned retrain
  • Catch it by segment-level and trigger analysis

Detect a Poisoned Retrain

35 min · advanced

0/3 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

A backdoor attack is best described as…

2

A poisoned retrain usually looks worse on clean metrics.

Go deeper

Official documentation