Manuscript Offprint

arXiv:2611.01342

J-Anchor: Defending Against Prefill Attacks via J-Space Selective Refusal Restoration

Running Yang, Beidi Zhao, Xiaoxiao Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Running Yang1,∗^{1,*}, Beidi Zhao1,2,∗^{1,2,*}, Xiaoxiao Li1,2,†^{1,2,\dagger}

1^{1}University of British Columbia, 2^{2}Vector Institute

Prefill jailbreaks can cause safety-aligned language models to continue an unsafe assistant prefix even when they would refuse the same request under normal decoding. We study how the model's internal harmfulness and refusal signals evolve along this attacker-controlled trajectory. Using the Jacobian lens, we track vocabulary-grounded harmfulness and refusal signals from the assistant header through prefilling and subsequent generation. We identify a characteristic phenomenon, which we call refusal-state erosion: both the refusal signal and the harmfulness signal weaken as the prefill progresses, but the refusal signal progressively declines to the benign baseline by the end of the prefill, while the harmfulness signal remains above its benign baseline and detectable during subsequent generation. Motivated by this observation, we introduce J-Anchor, a training-free inference-time defense that uses the model's pre-attack harmfulness and refusal signals as a request-specific anchor and selectively restores weakened refusal in J-space during prefilling and decoding. J-Anchor substantially reduces attack success under both fixed and deep prefill attacks across different model families. J-Anchor largely preserves benign behavior and reasoning ability, and ablations highlight the importance of targeted restoration in the J-space refusal subspace. Our results suggest that preserving latent refusal dynamics offers a promising route to robust defense against prefill jailbreaks.

1 Introduction

Large language models (LLMs) have made substantial progress in reasoning and problem solving (Guo et al., 2025; Yang et al., 2024), making their safe deployment increasingly important (Achiam et al., 2023). Yet safety-aligned models remain vulnerable to jailbreak attacks that elicit harmful responses (Zou et al., 2023; Chao et al., 2025). Recent studies reveal a striking disconnect: models can retain internal representations of harmfulness even when they fail to refuse harmful requests (Zhao et al., 2026a; Chua et al., 2026). Prefill jailbreaks provide a particularly revealing setting for investigating this disconnect: supplying the beginning of an assistant response can induce harmful continuation of a request that the model would otherwise refuse, without changing the request itself (Qi et al., 2025; Struppek et al., 2026). Understanding how an attacker-controlled continuation

Figure

Figure 1 Overview of J-Anchor. (a) A forced assistant prefix encourages unsafe continuation. J-Anchor establishes a request-specific anchor at the assistant header before processing the forced prefix. (b) J-Anchor reads refusal and harmfulness signals from vocabulary-grounded subspaces and calibrates them against benign activations. A request-level gate selectively enables restoration based on the anchor. During prefilling and decoding, J-Anchor selectively restores eligible refusal components toward anchor-derived targets. (c) These corrections steer the model away from unsafe continuation and toward refusal responses.

disrupts refusal despite preserved security-related information is therefore important for developing more reliable defenses.

Existing work has established that harmfulness-related representations and refusal behavior can dissociate, and that these signals can be detected, recovered, or manipulated at different stages of generation (Zhao et al., 2026a; Chua et al., 2026; Zhang et al., 2026a; Zhao et al., 2025; Sheng et al., 2026; Weng et al., 2026). What remains unclear is what happens between the model's initial secure response and the harmful continuation induced by a prefill attack. Unlike jailbreaks that operate solely through user-side prompts, prefill attacks directly fix an initial sequence of assistant-response tokens. This allows us to trace how harmfulness- and refusal-related representations evolve as the model processes an attacker-controlled response prefix. We therefore ask: how do harmfulness and refusal evolve across prefill depth, and how do their trajectories differ? This shifts the focus from static, single-position security-related readouts to the token-level dynamics of the prefill trajectory.

To study these dynamics, we use the recently introduced Jacobian lens (J-lens) (Gurnee et al., 2026), which maps intermediate representations into a vocabulary-grounded semantic space. Recent work has used J-space to expose latent security assessments before generation (Prosvirnin et al., 2026). We instead trace harmfulness and refusal from the assistant header, through each attacker-controlled prefill token, and into subsequent free generation. As shown in Figure 2(a), both signals weaken as the prefill grows deeper, but refusal attenuates markedly faster than harmfulness. By the onset of free generation, refusal can approach the benign baseline (with calibration described in Section 4.1) while harmfulness remains detectable. Attacks that ultimately fail also exhibit stronger refusal recovery during decoding. We refer to this asymmetric degradation as refusal-state erosion. These dynamics suggest that successful prefill attacks need not eliminate harmfulness-related

Figure

Figure 2 Refusal-state erosion and selective restoration with J-Anchor. (a) As attacker-controlled prefill tokens accumulate, the refusal signal fades while the harmfulness signal remains detectable. (b) Under prefill attacks, J-Anchor restores safe refusal on harmful requests while largely preserving benign behavior.

representations. Instead, refusal-related signals can progressively weaken along the prefill trajectory, leaving harmfulness-related information detectable even when the model fails to refuse.

This observation directly motivates J-Anchor, a closed-loop inference-time defense that preserves the refusal state established before the attack. Immediately before the attacker-controlled prefix, the assistant-header state reflects the model's response to the original request (Zhang et al., 2026a). J-Anchor uses the harmfulness and refusal signals at this position to construct a request-specific refusal target. As the prefill unfolds, it monitors the current refusal state in J-space and restores only the components that fall below this target; the same controller remains active during subsequent generation and re-engages if refusal drifts back toward compliance. Thus, the pre-attack state specifies what should be preserved, while the evolving state determines how much restoration is needed. Requests that the model does not register as risky are gated out.

We evaluate J-Anchor across four open-weight instruction-tuned models, multiple harmful and benign benchmarks, reasoning tasks, and both fixed and deep prefill attacks. J-Anchor substantially reduces attack success under both fixed and deep prefill attacks across different model families. Comparisons with representative defenses and ablations over intervention direction, representation space, restoration strength, and gating further validate the method while showing that benign behavior and reasoning performance are largely preserved.

Our contributions are threefold:

A new mechanistic view of prefill jailbreaks: refusal-state erosion. We reveal that refusal progressively erodes across attacker-controlled prefills substantially faster than harmfulness, while failed attacks show stronger refusal recovery. Controlled interventions further show that restoring refusal-related representations is critical for recovering refusal behavior under prefill attacks.

A novel defense principle: self-anchored refusal restoration. We introduce J-Anchor, which uses the model's harmfulness and refusal signals before prefilling as a request-specific anchor and continuously restores only the refusal lost during prefilling and subsequent generation. This yields a closed-loop, adaptive intervention without model fine-tuning or a separately trained harmfulness classifier.

Enhanced jailbreak robustness with preserved utility. Across four models and both fixed and deep prefills, J-Anchor substantially reduces attack success while keeping benign behavior and reasoning ability close to those of the undefended model.

References (62)