Manuscript Offprint

arXiv:2610.22640

SAFETYEDIT: Sparse Internal Targets with Prompt-Wide Control for LLM Jailbreak Backdoors

Yutong Ke, Yansu Wang, Zeyu Zhang, Xihao Guo, Chongwen Zhao, Kaizhu Huang

ABSTRACT

Model-editing backdoors aim to induce harmful responses under a trigger while preserving ordinary behavior on untriggered input. Recent model-editing approaches target affirmative response prefixes through rank-one updates to a small subset of model weights. Yet when this prefix-level target is satisfied, the model may still revert to refusal or produce a coherent, apparently compliant response that does not address the request. To overcome this limitation, existing internal-representation approaches shift focus from output tokens to dense, high-dimensional compliance directions in latent space. Existing representation-level approaches rely on preservation constraints to maintain conditionality, motivating us to ask whether a smaller internal target can offer a different effectiveness—preservation trade-off. Motivated by the comparable control capability of single-coordinate interventions, we investigate a sparse refusal-related MLP coordinate as this target. We propose SAFETYEDIT, which optimizes a single refusal-related coordinate and uses KV-cache marking in early attention layers to propagate a prefix-trigger signal across subsequent instruction positions. On some checkpoints a downstream MLP reader converts this signal into control of the coordinate, while on others the propagated signal alone suffices; the method is defined by the sparse target rather than by a fixed writer-reader pair. Across four open-weight LLMs and three dataset groups, SAFETYEDIT achieves the highest triggered Guard ASR in 11 of 12 comparisons and the highest mean StrongREJECT score in all 12, relative to the baselines evaluated for each model. Crucially, comprehensive ablation and behavioral audits confirm generally minimal changes in untriggered behavior and general capabilities in the tested configurations.

1 INTRODUCTION

Backdoor attacks embed a hidden vulnerability in a language model: an attacker-chosen trigger elicits harmful compliance, while the model behaves normally on ordinary inputs. Such backdoors are traditionally implanted by poisoning training or fine-tuning data (Rando & Tramèr, 2024; Xu et al., 2024), which demands access to the training pipeline and a costly retraining run, and does not apply when the attacker controls only a released checkpoint.

Post-hoc model editing removes both requirements. A single rank-one weight update installs a targeted association without retraining (Meng et al., 2022; Li et al., 2024), and recent work reuses this approach to implant jailbreak backdoors. These methods often share one control target, the model's output tokens. For example, ROME-style edits force an affirmative opener such as "Sure"; JailbreakEdit optimizes an affirmative response more directly (Chen et al., 2025); DualEdit additionally suppresses refusal-token probabilities to reduce subsequent refusal (Jiang et al., 2026).

However, output-targeted editing does not guarantee the completion of harmful tasks. For instance, an affirmative opener may not be a successful jailbreak: after the forced first tokens, the model can still fall back to refusal or continue fluently without ever delivering the harmful content — a safety fallback, one phenomenon addressed in prior work (Jiang et al., 2026; Yin et al., 2026). A

Figure

Figure 1: From target selection to positional coverage. A: illustrative response paths and surface/goal comparisons, not universal guarantees. B: dense and single-coordinate objectives; highlighted coordinates denote targets. C: Guard ASR for response-only, four-boundary-token and prompt-only interventions on Llama-3.1-8B, JailbreakBench-32 (§4.4).

response classifier may label such outputs as compliant even if they fail to meet the harmful request. Compliance classification alone can therefore overestimate harmful task completion.

Internal representations offer a control target beyond the output surface (Arditi et al., 2024). SteerEdit takes an important step in this direction by encoding a dense compliance direction into MLP weights (Yin et al., 2026). Yet, the ability to change refusal behavior is only one requirement of a backdoor: the change must depend on the trigger, while the model retains its original behavior on untriggered inputs. SteerEdit addresses this requirement through a constraint derived from untriggered reference activations. Its design motivates examining control capability and conditionality together, while leaving a further question: Must an effective conditional edit specify a full dense target direction?

Single-neuron interventions suggest that a sparse target may suffice. Kazemi et al. (2026) show that intervening on one refusal-related MLP coordinate can substantially alter refusal behaviour in the models they study. Our direct-intervention comparison likewise finds strong control capability for both a single coordinate and a dense direction under the tested settings ( §4.5§4.5). This motivates investigating whether a conditional weight edit can retain that capability while specifying only a validated refusal-related coordinate, rather than prescribing a full activation vector. However, a sparse control target does not imply a position-local intervention. The same MLP coordinate has a distinct activation at each token position. Hence, directly controlling it across a prompt need not have the same effect as controlling it only near the trigger or chat boundary. We therefore compare the same intervention across different position sets. On 32 JailbreakBench prompts with Llama-3.1-8B, prompt-only intervention achieves 96.9% Guard-based success compared with 31.2% when restricted to four boundary tokens (Figure 4(a)). For a weight-only backdoor, the required positional coverage must arise from the edited model itself, without runtime activation overrides. This raises an implementation question: how can a local trigger affect subsequent instruction positions while retaining a single-coordinate target?

To address this problem, we propose SAFETYEDIT, which uses early attention value writers to propagate a trigger-conditioned marker across subsequent prompt positions while optimising a single refusal-related coordinate. In its prefix configuration, the writers deposit a marker in cached attention values at the trigger, and ordinary attention carries it to subsequent instruction positions. When this propagated signal alone is insufficient to realise the target shift, SAFETYEDIT additionally uses a downstream MLP reader that converts the marker into direct control of the selected coordinate. The sparse target is shared across configurations; the explicit reader is therefore a realisation mechanism rather than the definition of the control objective. This KV-cache marking mechanism connects local triggering with cross-position control. Clean-input preservation losses limit changes when the trigger is absent. The trigger condition and control pathway are encoded through rank-one updates merged into existing weights, with no inference-time hooks or additional operators.

Evaluation examines both the control pathway and its behavioral effects. Marker knockouts and coordinate measurements test the contribution of the cached signal. Comparisons with JailbreakEdit and DualEdit cover four models and five corpora, with SteerEdit additionally evaluated on the two Llama models. The same responses are scored using a surface action taxonomy, a harmfulness classifier, and the StrongREJECT rubric. On Llama-3.1-8B/JailbreakBench-100, SAFETYEDIT reaches 89.0% triggered Guard ASR and 77.5 StrongREJECT, versus 73.0% and 63.8 for the strongest baseline, SteerEdit (Table 1). Separate goal-completion diagnostics and clean capability benchmarks assess request fulfillment and dormant-state side effects.

Our contributions are threefold:

• We reveal that a sparse control target can require broad positional coverage. In the tested Llama-3.1-8B setting, restricting intervention to boundary tokens does not reproduce prompt-wide control, showing that target sparsity alone does not determine where intervention must act.

• We propose SAFETYEDIT, a weight-only construction that connects a local trigger to prompt-wide single-coordinate control through trigger-gated attention writers, optionally supplemented by a downstream MLP reader. Rank-one updates merge into existing weights without inference-time hooks; targeted marker knockouts test the cached signal’s causal contribution.

• We evaluate surface compliance and harmfulness across models and datasets, alongside untriggered safety and capability preservation. A fixed-response goal-completion analysis shows why apparent compliance alone is insufficient to establish harmful task completion.

References (30)