Backdoors as Broken Commutativity: Detecting and Repairing Trojans by Testing Whether the Task Variable Still Controls the Output

A backdoored network behaves normally until it sees a secret trigger, a patch, a word, or a style, and then outputs whatever the attacker chose. Most defenses look for the trigger itself, by perturbing inputs or searching small perturbation budgets, so each one breaks when the trigger takes a new form. This proposal looks for the mechanism instead. Interpretability research can find a small internal subspace that carries the task's key variable, for example "which class is this image" or "what sentiment does this sentence express." The subspace is validated by an interchange intervention: the subspace contents from one input are copied into the model's computation on another, and the test is whether the output changes the way the variable predicts. On clean inputs, this simple story of the task holds under intervention. On a triggered input, the backdoor overrides the story, and the task variable stops controlling the output. We propose to measure this loss of control per input and per layer. The measurement gives a detector that does not need to know the trigger's form. It also tells us where in the network the override happens. And it supplies a repair objective: retrain until the task variable controls the output again.

The formal notion behind this is interventional consistency from causal abstraction. A high-level causal model, such as "class → output," is a valid summary of a low-level system, here the network's activations, only if intervening and then summarizing gives the same result as summarizing and then intervening (Causal Consistency of Structural Equation Models, Abstracting Causal Models). Our claim is that a backdoor is a region of input space where this commutation fails for the clean task's abstraction. That failure can be measured without clean-versus-poisoned labels and without a model of the trigger.

Core Claim

We fit an alignment of the clean task variable once, using Distributed Alignment Search. This method, used in Combining Causal Models for More Accurate Abstractions of Neural Networks, learns a rotation of a layer's activations such that a $k$-dimensional subspace behaves like a high-level variable under interchange. The fit uses the model's own training data. For a test input $x$, we patch that subspace at layer $l$ with its contents from each reference input $r$ in a small labeled pool $\mathcal{R}$, and we record how often the output follows the reference:

$$ c_l(x) = \frac{1}{|\mathcal{R}|}\sum_{r \in \mathcal{R}} \mathbb{1}\left[f\left(x;\, S_l \leftarrow S_l(r)\right) = y_r\right] $$

Here $f(x; S_l \leftarrow S_l(r))$ is the model's prediction on $x$ when the aligned subspace $S_l$ is overwritten with its value on $r$, and $y_r$ is the model's own clean prediction on $r$. On clean inputs, $c_l$ should match the interchange-intervention accuracy of the alignment. Neuron-level abstractions reach 88–100% on SST-2 and other benchmarks (Neuron Dependency Graphs). On triggered inputs, $c_l$ should collapse toward the rate of references whose label already equals the attacker's target class, because the trigger pins the output.

The layer profile $l \mapsto c_l(x)$ is the second product. For each layer we compare $c_l$ on triggered and clean inputs, and the first layer where the two diverge localizes the override. This directly tests an open tension in the literature. When Backdoors Speak finds that the target label emerges only in the final layers and that the model becomes "blind" to input context. BEEAR instead finds separable drift at intermediate layers 9–12. Loss of control of the task variable is exactly the causal version of "contextual blindness." Profiling it across layers can show whether the intermediate drift causes the late emergence.

Relation to Prior Work

The closest work is Faithful Bi-Directional Model Steering. That paper uses distributed interchange interventions to steer a Llama-3.1 sleeper agent away from a backdoor concept, and it needs a target distribution for that concept. We never model the backdoor. We model only the clean task and read the backdoor off as the place where the clean model stops commuting. This matters because the defender usually does not know what the backdoor concept is. BEEAR similarly optimizes against a drift direction in embedding space, not a validated task variable.

Two causal defenses use causal graphs at the input–output level but no internal abstraction. FABE (Causality Based Front-door Defense) paraphrases inputs through an external LLM and applies front-door adjustment. CBD (Deconfounded Representation Learning) separates confounding from causal features using early stopping and a mutual-information penalty. Neither maps internal activations to task variables, and FABE costs 11.98 seconds per query.

The causal-abstraction papers supply our method but have only ever studied clean models: neuron dependency graphs, piecewise combined abstractions, and the faithfulness desiderata in Three Desiderata for Faithfulness. Two of their findings constrain our design. First, single abstractions cover under 50% of behavior on simple GPT-2 tasks, so we must use a per-layer, piecewise alignment rather than a single global one. Second, patching can produce out-of-distribution "illusions," which is why random-subspace patching is a central control below.

Research Program

We build the method in three stages.

The first stage is alignment on possibly-poisoned data. We fit Distributed Alignment Search for the class variable at every candidate layer on the training set as delivered, including its poison. We test how alignment quality and detection degrade as the poison rate rises from 1% to 50%, the range Shared Adversarial Unlearning reports robustness over. We compare this against fitting on a 5% trusted subset. We do not claim to need zero clean data up front. Whether the poisoned-data fit suffices is an empirical question the program settles.

The second stage is detection and localization through the score $c_l$ and its layer profile. The score is thresholded at a preset 1% false-rejection rate on held-out data, which matches STRIP's protocol.

The third stage is consistency-restoring repair. We fine-tune with interchange-intervention training on flagged inputs used as bases: after patching in $S_l(r)$, the model must output $y_r$. This forces the task variable to regain causal control in the presence of the trigger, without ever labeling the flagged inputs. If the trigger does not overwrite the task subspace itself, the repaired model's unpatched output on a triggered input should then follow that input's own class content. In that case robust accuracy, not just a low attack success rate, should rise.

Baselines

The naive reference is the undefended model thresholded on its own output confidence. This establishes how much of any detection result is trivial.

For detection, the strongest trigger-agnostic competitor on vision is MSPC (Backdoor Secrets Unveiled). It detects poisoned samples through scale-invariant prediction consistency, and it reports an average AUROC of 0.8941 on CIFAR-10. We run it on identical BackdoorBench-poisoned models and data using its released protocol. Beating it means a higher average AUROC over the same attack set, and especially on the style and warping attacks it concedes.

STRIP (STRIP) is the strongest runtime input filter. It reports 0% false acceptance in most CIFAR-10 and GTSRB cases at a preset 1% false-rejection rate, with 1.32x latency. We give it the same number of forward passes per query as our reference pool. Beating it means lower false acceptance at equal false rejection and equal compute on partial, source-specific, and warping backdoors.

A supervised internal-feature probe in the style of When Backdoors Speak reports 98.8% accuracy, but it is trained with known backdoored examples. We treat it as an oracle upper bound and test its transfer across attack types.

The key ablation replaces the aligned subspace with a random rotation of the same dimension, and separately with full-layer patching, at identical cost. If random patching detects equally well, then the "consistency" story adds nothing beyond activation noise.

For repair, the baselines are SAU, which reports 2.51% average ASR across seven CIFAR-10 attacks with accuracy within 1–2%; Fine-Pruning; CBD, which reports about 1.6% ASR; and, for text, FABE, which reports 15.12% average ASR and 85.52% clean accuracy on SST-2, Offenseval, and HSOL. Every method gets the same clean-data allowance and a matched tuning budget. Beating a baseline means matching its ASR while achieving higher robust accuracy, or beating it outright on the large-norm and warping triggers where norm-ball methods fail.

Why not just…?

Why not just use STRIP or MSPC, which need no internals? Both look for properties of the trigger. STRIP weakens on partial backdoors, and MSPC admits failure on style-transfer attacks like DFST. Our score depends on how the output is controlled, not on how the trigger looks. The WaNet, SSBA, SynBkd, and style-attack comparisons at matched compute will show whether this matters in practice. If STRIP ties us on those attacks, the internal machinery is not worth its cost, and we will say so.

Why not just train a probe on activations to spot triggered inputs? A probe needs triggered examples, and the 98.8% figure is supervised. We will train a probe on BadNets and test it on WaNet and AddSent, then compare it with our untrained score. A real threat is that a probe trained on synthetic triggers generalizes well. If it does, our advantage shrinks to localization and repair.

Why not just patch random directions, which is cheaper and needs no alignment? This is the most important alternative, because it would reduce our method to a latent-space STRIP. The random-subspace ablation settles it directly. We expect the aligned subspace to separate clean from triggered inputs much better, because random patches mostly destroy clean behavior too.

Why not just prune dormant neurons or use SAU? Fine-Pruning left about 30% ASR on traffic signs and fails when the attacker forces backdoors to share circuits with clean behavior. SAU depends on norm-bounded search. Our repair does not assume dormancy or small triggers. Pruning-aware and warping attacks are the planned test.

Proposed Experiments and Decisive Checks

For vision, we use BackdoorBench on CIFAR-10, GTSRB, and Tiny ImageNet with PreActResNet and EfficientNet. The attacks are BadNets, Blended, WaNet, SSBA, and a style attack. Including a second architecture is deliberate: BackdoorBench reports defenses that collapse across architectures. For text, we use SST-2, Offenseval, and HSOL with BadNets, AddSent, and SynBkd on BERT and a LLaMA-family model. The metrics are AUROC, false acceptance at 1% false rejection, ASR, clean accuracy, robust accuracy, and seconds per query.

Three checks decide whether the idea stands. The first is whether the aligned subspace beats random patching by a wide AUROC margin. The second is whether the first divergent layer in the $c_l$ profile predicts where intervention-based repair works best, which would settle the tension between intermediate drift and late emergence.

The third check is an adaptive attack that we build ourselves. The attacker trains the trigger to write the target class into the aligned subspace rather than bypass it. Commutation then holds, and our detector should fail. We predict the attack is costly: it requires knowing the defender's alignment and competes with clean features. We will report its ASR and its clean-accuracy cost honestly as the method's boundary.