A backdoor attack plants a secret rule in a model through poisoned training data. The attacker stamps a small pattern, the trigger, onto some images and relabels them to a chosen target class. The finished model behaves normally until it sees the trigger, at which point it outputs the target. A tempting defense comes from invariant feature selection, which learns only the features whose relationship to the label stays the same across different data sources ("environments"). The hope is that such a model discards the trigger the way it discards a grass background that happens to predict "cow."
This note argues that the hope is backwards, and that the reversal is useful. In poisoned data the trigger is not a spurious feature. It is a genuine cause of the label, and the rule "trigger present means target class" holds with probability one in every environment that contains the trigger. The feature whose relationship to the label shifts across sources is the object's actual appearance, because the attacker has overwritten that relationship on a subset of samples. Invariance-based learners should therefore keep the backdoor. The right way to use invariance is to treat the unknown trigger as a hidden environment switch: search for the group of samples on which the appearance-to-label rule breaks. Finding that group removes the poison and recovers the true labels of triggered inputs.
Core Claim
The claim has a negative half and a constructive half. Let $C$ be the semantic content of an input and $T$ an indicator that the trigger is present. Let $Y$ be the observed label, and let $\rho_e$ be the fraction of poisoned samples in environment $e$.
Under dirty-label poisoning (poisoned samples come from many true classes and are relabeled), the predictor "output the target if $T=1$, else classify $C$" is Bayes-optimal and exactly invariant in every environment. By contrast, $P(Y \mid C)$ drifts with $\rho_e$. Any method that selects features which are both invariant and maximally informative will therefore keep $T$. This includes invariant risk minimization (Arjovsky et al.), Markov-blanket selection over learned latents (CMBRL), and entropy-parity masks (InvariantStock). A Markov blanket is the smallest feature set that makes the label independent of everything else, and the trigger belongs to it because it is a direct parent of $Y$ in the poisoning process.
This contradicts the framing used by the closest causal defense. Backdoor Defense via Deconfounded Representation Learning (CBD) draws the attack as a confounder $X \leftarrow B \rightarrow Y$. CBD works in practice, but it relies on early stopping to isolate trigger features, not on invariance.
The constructive half flips the roles. The trigger's signature is not instability of $P(Y \mid T)$. It is that the trigger switches off the $C \to Y$ mechanism: inside the poisoned group, labels are constant while content spans many classes. We therefore infer a soft partition $q(x) \in [0,1]$ of the training set that maximally violates invariance for a content-only predictor. The violation is measured as
$$V(q) = H(Y \mid C) - H(Y \mid C, E_q),$$
where $H$ is conditional entropy estimated by a probe on content features and $E_q$ is the environment label induced by $q$. This is the same parity quantity InvariantStock drives to zero; here we maximize it. We add two constraints: the flagged group must have a single dominant label (coherence), and it must be small. The flagged group is removed, or relabeled by the content-only predictor. That predictor also serves at test time to recover true labels.
Relation to Prior Work
Four lines of work motivate or constrain the proposal.
CBD and Mind Control through Causal Inference (MCCI) show that causal decompositions can defeat backdoors. Each carries an assumption we drop. CBD assumes triggers are learned faster than semantics. MCCI assumes triggers leave frequency-domain marks, which it absorbs with a small network that reads the image's discrete cosine transform (DCT) spectrum. MCCI also supplies a key empirical premise for us: the semantic latent space of a poisoned model still clusters poisoned images by their true class. Our partition search exploits exactly that fact.
Causality Based Front-door Defense does the analogous thing in text through paraphrase, at 11.98 seconds per input. We do not address text.
On the invariance side, Does Invariant Risk Minimization Capture Invariance? constrains the design. It shows that the practical IRM relaxation (IRMv1) can rely more on shortcuts than plain training, with Two-Bit test loss 0.38 versus 0.28 for ERM. ERM here means empirical risk minimization, ordinary training on the pooled data. That result is one reason we use invariance as a detection statistic rather than as a training penalty. Stable Adversarial Learning and CMBRL supply the invariant learners we stress-test.
On the attack side, Persistent Backdoor Attacks in Class-Incremental Learning shows that attackers deliberately anchor triggers in subspaces that stay above 80% similar across tasks. We read this as independent evidence that invariance favors the attacker, which is our negative claim.
Research Program
The first component is a short formal result plus a controlled demonstration. The result states that under dirty-label poisoning with environment-varying $\rho_e$, the trigger-using predictor is the unique invariant, maximally informative one, while clean-label poisoning produces no invariance violation at all. The demonstration adds a patch trigger to Colored MNIST, a digits benchmark where color predicts the label during training and the correlation flips at test time. We then run IRMv1, SAL, a CMBRL-style pipeline (an identifiable variational autoencoder followed by Markov-blanket search) and an InvariantStock-style mask. Our prediction is that these methods discard color, as they are designed to, but keep the patch. Attack success rate (ASR, the fraction of triggered inputs sent to the target class) should stay near ERM's level. The prediction is falsified if ASR drops substantially.
The second component is the partition search. Content features $C$ come from one of three encoders, compared as an ablation. The first is a self-supervised model trained on the poisoned images without labels. The second is the penultimate layer of an ERM model trained on the poisoned data, following MCCI's observation. The third is a public CLIP encoder. The probe for $H(Y \mid C)$ is a linear or small MLP head. The partition $q$ is optimized by alternating two steps: fit probes with and without $E_q$, then update $q$ to increase $V(q)$ under the size and coherence constraints. Multiple target classes are handled by searching for several coherent groups.
After the search, a final model is trained on the retained data. The content-only probe is kept as a fallback classifier, and inputs where the final model and the probe disagree are routed to the probe. This routing is what should raise true-label recovery on triggered inputs, measured as the attack recovery rate (ARR, also called robust accuracy).
Baselines
The naive reference point is ERM on the poisoned data. BackdoorBench reports that it yields ASR near 100% with little loss of clean accuracy across architectures (BackdoorBench). Any method must beat it on ASR while staying within about one point of its clean accuracy.
The strongest removal baseline is CBD. It trains an early-stopped backdoored model, then trains a clean model penalized for sharing information with it. It reports average ASR of about 1.6% across CIFAR-10, GTSRB and an ImageNet subset against six attacks, with 10–20% training overhead. It does not report true-label recovery.
The strongest recovery baseline is MCCI, reported at about 85% ARR on CIFAR-10.
The cheapest post-hoc baseline is batch-normalization-statistics pruning (Pre-activation Distributions Expose Backdoor Neurons). It prunes neurons whose pre-activation statistics are bimodal and reports ASR under 1% on CIFAR-10 with clean accuracy within 1%, in 0.39 seconds.
We also run the simplest version of our own idea. This semantic-disagreement filter flags any sample whose label disagrees with the majority label of its nearest neighbors in the same content space. No reported result was found on Lacuna for this filter, so we will establish its numbers ourselves. It isolates what the invariance formulation adds beyond per-sample disagreement.
A final ablation removes the coherence constraint from $V(q)$. This tests whether the group-level switch structure matters or whether we are just filtering hard examples.
For fairness, all methods use BackdoorBench's attack implementations, architectures and poisoning ratios. They share the same content encoder where one applies, the same clean-sample budget for methods that need one, and an equal hyperparameter search budget in GPU hours.
Beating CBD means matching its ASR on standard attacks while clearly exceeding it on attacks built to learn at benign speed. Beating MCCI means matching its ARR on frequency-marked attacks and exceeding it on spatial warping (WaNet), which leaves no DCT anomaly.
Why not just…?
Why not just prune with batch-norm statistics? Pruning is fast and strong on CIFAR-10, and we expect it to tie us there. Its own authors note it weakens when mixture moments are close, as with the Refool attack, and it is not designed to recover true labels. We will report where it ties us rather than claim a universal win. The decisive comparisons are on Tiny-ImageNet, on attacks designed to evade detection such as SPD (SPD), and on ARR.
Why not just filter samples whose label disagrees with semantic neighbors? This is the real threat, because it is a per-sample approximation of the same signal. It could match us whenever the encoder is strong. Our prediction is that the group-level statistic degrades more slowly as encoder quality drops, because it pools evidence across the whole coherent group. It should also remove fewer naturally hard or mislabeled clean samples, because random label noise lacks a single dominant target. We test this by sweeping encoder quality: self-supervised on poisoned data, then poisoned ERM, then CLIP. We also inject random label noise alongside the attack. If the filter matches us at every encoder quality, the honest conclusion is that the invariance lens explains why the simple filter works, not that a new method is needed.
Why not just apply IRM or Markov-blanket selection over multiple data sources? This is the obvious combination, and the negative half of the claim predicts it fails for a structural reason rather than an optimization one. The Colored MNIST patch experiment, together with multi-source CIFAR-10 in which sources differ in poisoning rate, settles the question directly.
Why not just rely on early stopping, as in anti-backdoor learning or CBD? BackdoorBench documents the poisoning paradox: at low poisoning ratios the gap in training loss between clean and poisoned samples shrinks, so loss-based isolation stops working. Our statistic does not depend on learning speed. The experiment that settles this is the low-ratio sweep.
Proposed Experiments
Experiments cover CIFAR-10, GTSRB and Tiny-ImageNet under BadNets, Blended, WaNet, frequency-domain and SPD attacks across BackdoorBench's poisoning ratios, using PreAct-ResNet18 and one harder architecture such as EfficientNet. We report clean accuracy, ASR, ARR, and precision and recall of poisoned-sample detection, together with the number of clean samples wrongly removed.
Four checks decide the outcome. The first is whether invariant learners keep the Colored MNIST patch and the multi-source CIFAR-10 trigger. The second is whether the partition search beats the semantic-disagreement filter as encoder quality degrades. The third is whether ARR exceeds MCCI's reported 85% on WaNet, where MCCI's frequency assumption fails. The fourth is the predicted failure under clean-label poisoning, where our own analysis says no mechanism switch exists; there we expect the method to leave ASR high and will report that as the stated boundary.
A multi-target adaptive attack, which spreads relabeled samples across several target classes to dilute coherence, tests how much the coherence constraint can be gamed.
References
- Invariant Risk Minimization
- Integrating Markov Blanket Discovery Into Causal Representation Learning for Domain Generalization
- InvariantStock: Learning Invariant Features for Mastering the Shifting Market
- Backdoor Defense via Deconfounded Representation Learning
- Mind Control through Causal Inference: Predicting Clean Images from Poisoned Data
- Causality Based Front-door Defense Against Backdoor Attack on Language Models
- Does Invariant Risk Minimization Capture Invariance?
- Stable Adversarial Learning under Distributional Shifts
- Persistent Backdoor Attacks in Class-Incremental Learning via Structural Invariant Anchoring
- BackdoorBench: A Comprehensive Benchmark of Backdoor Learning
- Pre-activation Distributions Expose Backdoor Neurons
- SPD: Shallow Backdoor Protecting Deep Backdoor Against Backdoor Detection