Forward-Only Fine-Tuning as an Accidental Backdoor Eraser

A backdoored model behaves normally on ordinary inputs but switches to an attacker's chosen behavior when a secret trigger, such as a rare word or a pixel patch, appears in the input. Defenders often try to repair such a model by fine-tuning it on a small amount of clean data. This tends to fail for a structural reason: the backdoor lives in parameters that clean data never exercises, so their gradients are near zero and backpropagation leaves them untouched. Zeroth-order fine-tuning works differently. It estimates gradients from loss values alone, by nudging the weights along a random direction and seeing whether the loss goes up or down. Each step therefore moves every parameter along that random direction, including the ones clean data ignores. This note proposes to test a specific, falsifiable claim. Forward-only fine-tuning on clean data erodes backdoors that first-order clean fine-tuning preserves. It does so by injecting a random walk into the "dormant" parameters the backdoor occupies, and the size of that walk is set automatically by the clean loss, so clean accuracy is spared.

If the claim holds, defenders get a cheap repair method that uses no trigger knowledge and needs only forward passes. It would run in the memory footprint that lets zeroth-order methods fine-tune 70B models on consumer hardware. If the claim fails, and the erosion turns out to equal what plain weight noise achieves, we learn that zeroth-order training is no safer than ordinary training. That result also matters, because forward-only fine-tuning is spreading as an on-device adaptation method.

Core Claim

The standard two-point zeroth-order step perturbs the weights $\theta$ by a random Gaussian direction $u$ of size $\mu$, measures the clean loss $L$ on both sides, and updates

$$\Delta\theta = -\eta \, \frac{L(\theta+\mu u)-L(\theta-\mu u)}{2\mu}\, u \approx -\eta\,(u^\top \nabla L)\,u,$$

where $\eta$ is the step size. This is the estimator used in ZO-AdaMM. On average over $u$, the update equals the true gradient. Any single step, however, is dense. Take a unit direction $v$ orthogonal to the clean gradient, such as a weight feeding a neuron that only fires on the trigger. Because $u^\top\nabla L$ and $u^\top v$ are independent for Gaussian $u$, the expected squared movement along $v$ per step is $\eta^2\|\nabla L\|^2$. Over $T$ steps the dormant directions accumulate displacement of roughly $\eta^2\sum_t \|\nabla L_t\|^2$, while first-order clean fine-tuning moves them by approximately zero.

Two predictions follow. The first is that zeroth-order clean fine-tuning should lower attack success rate more than first-order clean fine-tuning at equal clean accuracy. The second, and the more important, is that this "noise" is self-scheduled: it is large early, when clean loss is high, and it shrinks near convergence. It may therefore disturb the backdoor more per unit of clean-accuracy loss than isotropic weight noise of matched total norm. The second prediction is what separates a real finding from the trivial observation that noise damages things.

Relation to Prior Work

The motivating evidence comes from Fine-Pruning, which shows that backdoors concentrate in dormant neurons and sub-networks that clean inputs leave inactive. That is exactly the null space of the clean gradient described above. Trojaning Language Models for Fun and Profit shows the same spare-capacity effect in transformers. Fine-Pruning removes these neurons by explicit pruning. We instead ask whether an optimizer that does not respect the gradient's null space reaches dormant parameters as a side effect.

The method comes from the zeroth-order fine-tuning line. LOZO restricts random perturbations to low-rank matrices and reaches near first-order accuracy on LLMs. It reports 61.6% on MNLI with RoBERTa-large against 56.7% for the isotropic MeZO baseline. LOZO matters doubly here. It is a practical optimizer, and it is a natural ablation, because confining perturbations to a low-rank subspace should reduce incidental contact with dormant backdoor parameters. Our mechanism therefore predicts that LOZO erases less than isotropic perturbation. The smoothing view in Gradient-Free Methods for Deterministic and Stochastic Nonsmooth Nonconvex Optimization tells us what zeroth-order steps optimize, namely a smoothed loss. It does not address what they do to parameters the loss ignores, which is the question here.

The closest existing work combining zeroth-order methods and backdoors is about detection, not repair. B3D inverts vision triggers with evolution-strategy search gradients. AEVA uses Monte Carlo hard-label gradient estimation to flag infected classes. Neither changes the model. ZeroFisher uses zeroth-order information for unlearning, but only for privacy deletion in knowledge-graph embeddings, with no adversary.

On the repair side, BAERASER and Don't Shift the Trigger (RGA) unlearn backdoors through first-order gradient ascent on a recovered or known trigger. RGA constrains our design in one specific way. It proves that naive gradient ascent on the target class pushes triggered inputs toward a different class rather than restoring correct behavior. Our method never ascends a trigger loss, so it should not shift the trigger in that directed way. This is a prediction we will check rather than assume, because a random walk could still settle on a new spurious target.

The obvious gap-filling project would be a zeroth-order port of RGA, replacing backprop with LOZO estimates in trigger-ascent unlearning. We deliberately avoid it. A defender who holds the weights and a known trigger can run first-order RGA with low-rank adapters cheaply, so the port would be a weaker copy of an existing method. The question here does not need the trigger at all.

Research Program

We first build a mechanism testbed in which "dormant" can be measured directly. We implant BadNets-style patch backdoors in ResNets on CIFAR-10. Using held-out triggered inputs that the defender never trains on, we identify trigger-selective units as those whose activation on triggered inputs far exceeds their activation on clean inputs. We then fine-tune on 1% clean data, the budget BAERASER reports as sufficient. Each run uses one of four procedures: first-order SGD, isotropic two-point zeroth-order, low-rank zeroth-order in the style of LOZO, or first-order SGD plus matched Gaussian noise. Throughout each run we log the displacement of trigger-selective weights, the clean gradient norm, attack success, and clean accuracy. This directly tests the displacement prediction $\eta^2\sum_t\|\nabla L_t\|^2$.

We then move to language models on the RGA benchmark suite. The models are Llama-2-7B and Qwen3-8B. The data are SST-2, AG News and HSOL, poisoned with BadNets rare-word triggers, AddSent sentence triggers and HiddenKiller syntactic triggers. Clean fine-tuning uses only a small clean split. We also include a RoBERTa-large tier so that compute-matched sweeps stay affordable.

The third component is an adaptive attacker. A backdoor trained to survive random weight perturbation, for example by adding Gaussian weight noise during poisoning, is the natural counter to our mechanism. We measure how much of the effect survives it. A defense that only works against unaware attackers will be reported as such.

Baselines

The naive reference point is the backdoored model left untouched, alongside the same model after zero steps of each procedure with identical evaluation. This anchors attack success and clean accuracy before repair.

The most important competitor is first-order clean fine-tuning on the same clean split. It uses the same number of data examples, the same tuning budget of 20 configurations over learning rate and steps, and the same model-selection rule: the best clean validation accuracy, never the attack success rate, which a real defender cannot observe. It is the strongest competitor because it shares every ingredient except the optimizer, and it is the default defense practitioners reach for. We run it both with full backprop and with LoRA, so that the comparison is not confounded by memory budget. Beating it means a lower attack success rate at clean accuracy within one point of it, across at least two of the three trigger types.

The key ablation is first-order fine-tuning plus isotropic Gaussian weight noise. We match the noise to the zeroth-order run's total per-step dormant displacement, under both a constant schedule and a schedule following the observed $\|\nabla L_t\|$. This isolates whether zeroth-order training contributes anything beyond "noise plus descent." A second ablation compares isotropic and low-rank perturbations to test whether perturbation coverage drives erasure.

For trigger-free pruning we run Fine-Pruning under the same clean data. No reported result for Fine-Pruning on these language benchmarks was found on Lacuna.

As a white-box upper reference with oracle trigger knowledge we run RGA. It reports roughly 90% poisoned accuracy, meaning triggered inputs receive their correct label, on SST-2 with Llama-2 under AddSent, against roughly 50% for vanilla gradient ascent. We do not expect a trigger-free method to beat RGA. Reaching within 10 points of its poisoned accuracy without knowing the trigger would count as a strong result. On vision, BAERASER reports a 99% average reduction in attack success with clean-accuracy drops typically under 5%, and it serves as the CIFAR reference.

All methods are matched on forward-pass count as well as on steps. A zeroth-order step costs two forward passes, and a first-order step costs roughly three forward-equivalents.

Why not just…?

Why not just add noise to the weights and fine-tune normally? This is the most serious threat. If matched Gaussian noise plus first-order fine-tuning erases backdoors as well as zeroth-order training at the same clean accuracy, the claim collapses into a known noise-injection effect, and we will report it that way. The proposal survives only if the self-scheduled, loss-coupled zeroth-order walk achieves a better trade-off between attack success and clean accuracy than noise matched on total displacement. The noise ablation in the Baselines section is designed to settle exactly this.

Why not just prune the dormant neurons? Fine-Pruning does this explicitly and may well win on vision patch triggers, where backdoors localize. Its weakness is that it needs an activation threshold and assumes the backdoor is localized in a few neurons. Distributed triggers such as HiddenKiller's syntactic patterns may not be. Zeroth-order perturbation needs no localization assumption. If pruning dominates on all three trigger types, the method has no niche outside the memory-constrained setting.

Why not just run RGA with LoRA, since the defender holds the weights? When the trigger is known, that is the right tool, and we treat it as an upper reference rather than a competitor. Our setting is the more common one in which the defender suspects a backdoor but has neither the trigger nor a reliable way to invert it in text. In that setting RGA cannot start. Comparing against LoRA first-order clean fine-tuning addresses the memory argument fairly.

Decisive Checks

Four checks decide the outcome, and each can fail. On CIFAR-10, the measured displacement of trigger-selective weights should track $\eta^2\sum_t\|\nabla L_t\|^2$ under zeroth-order training and stay near zero under first-order training. If it does not, the proposed mechanism is wrong even if attack success happens to drop. On the RGA language suite, zeroth-order clean fine-tuning should beat compute-matched first-order clean fine-tuning on attack success at equal clean accuracy. It should also beat matched-noise fine-tuning. Low-rank LOZO should erase measurably less than isotropic zeroth-order training. Finally, we count the fraction of triggered inputs that land on any single non-original label, the trigger-shifting measure from RGA. This rate should stay near the clean model's misclassification rate rather than concentrating on a new class.

A positive result on the first two checks and a failure against the noise-robust adaptive attacker would still be publishable. It would show that zeroth-order training is a cheap, trigger-free repair for backdoors that are not robust to noise, together with a clear statement of how to defeat it.