Inference-Time Vulnerability Beyond Shallow Safety: Alignment Along Generation Trajectories

Kyungmin Park, Taesup KimNeurIPS 2026

TL;DR

Safety-aligned Large Language Models (LLMs) are surprisingly easy to derail: forcing just a few words into their responses mid-sentence can flip a firm refusal into full compliance with a harmful request. This paper reveals that an LLM's internal "refusal state" offers almost no resistance to mid-stream hijacking, and solves the problem by training models on perturbed generation trajectories so they learn to actively steer themselves back to safety.

What Problem Does This Paper Address?

Even after extensive safety training (like RLHF or DPO), LLMs remain vulnerable to jailbreaks. Many attacks—whether optimizing weird prompt suffixes or simply "prefilling" the assistant’s first few words with "Sure, here is"—work by hijacking the start of the response. Once the model utters an affirmative opening, its autoregressive nature takes over, and it happily completes the harmful request.

Recent work dubbed this "shallow safety," arguing that alignment mostly just shapes the probability distribution over the first few output tokens. Park and Kim ask a deeper question: Is this fragility really confined to the beginning of a response, or is the entire generation process vulnerable?

As it turns out, shallow safety is just the tip of the iceberg. If a model is already several words into a polite refusal, injecting a short harmful phrase mid-sentence is still enough to completely redirect it into generating dangerous content. Standard alignment trains models on static, complete prompt-response pairs—meaning models never learn how to recover once their generation trajectory gets bumped off course.

Figure 1: Attack success rate (ASR) when a short harmful or refusal sequence is injected at each generation step. Both injection types substantially shift ASR relative to the uninjected baseline (dotted line), with the effect strongest at early steps but persisting throughout generation.

Methods

To teach models how to recover mid-flight, the authors introduce Trajectory-Level Safety Alignment, built on three core steps:

  1. Tracking Internal States: First, they map out what "refusal" and "compliance" look like inside the model's last-layer hidden states by averaging representations across safe and unsafe generations (creating difference-in-means prototypes).
  2. Bidirectional Trajectory Augmentation (The Novel Twist): Instead of perturbing input prompts, they intervene during decoding. While the model responds to a harmful prompt, they monitor its hidden state. As soon as its cosine similarity with the refusal prototype crosses a threshold—meaning the model is firmly in "refusal mode"—they inject a short harmful phrase (e.g., "Certainly!") and let the model finish. Conversely, if a model starts complying, they inject a refusal phrase ("I can't fulfill that request") to steer it back to safety.
  3. Iterative SimPO Training: Pairing these hijacked trajectories with the original unperturbed responses gives clean (prompt, safe_trajectory, unsafe_trajectory) triplets. They optimize the model using SimPO (a reference-free preference optimization algorithm) with QLoRA. Because training shifts the model's internal representations, they repeat this data-collection and training loop iteratively—much like adversarial training—to catch lingering failure modes.

Datasets

No new benchmarks are introduced; instead, the authors rely on a comprehensive suite of existing datasets:

  • Training & In-Domain Safety: AdvBench (split into non-overlapping training and test sets).
  • Out-of-Domain Safety: HarmBench, HEx-PHI, and JailbreakBench.
  • Over-Refusal (False Positives): XSTest and OR-Bench (testing if models become overly paranoid on benign prompts that merely look sensitive).
  • General Capabilities & Helpfulness: MMLU, PROST, MT-Bench, and AlpacaEval 2.0.

Key Insights and Ideas

  • "Refused, But Didn't Resist": You might expect that if a model's internal hidden state is strongly aligned with its "refusal direction," it would resist harmful token injections. The authors find the exact opposite: across Mistral, Llama, and Qwen, hidden states showing the highest similarity to the refusal prototype still suffer massive Attack Success Rates (ASR). Occupying a safe internal state does not mean that state is stable.
Figure 3: Relationship between refusal-prototype similarity (x-axis) and attack success rate (y-axis). At each generation step, the hidden state before injection is paired with the attack outcome at that step. Bars show mean ASR per bin; lines show sample counts. The base model “refused but didn’t resist”: occupying the refusal region did not confer resistance to injection at that step. The same pattern holds across three model families (Mistral, Llama, Qwen).
  • Coherence Trumps Safety: Projecting hidden-state trajectories onto a 2D PCA plane shows why this happens. The exact moment tokens are injected, the model's internal trajectory sharply pivots out of the refusal region into the compliance region to maintain a coherent continuation of the injected text.
PCA trajectory plot showing sharp divergence from refusal to accept regions at the injection step.
  • Displacement Alone is Dangerous: Even injecting completely benign, non-harmful filler phrases mid-generation spikes Llama-3.1-8B's ASR to 26.3%. Simply knocking the model off its expected trajectory creates vulnerability.

Key Results

Evaluated on Llama-3.1-8B-Instruct, Mistral-7B-Instruct-v0.3, and Qwen2.5-7B-Instruct using LlamaGuard (LG) and OpenAI Moderation (OM) as judges:

  • Crushing Mid-Sequence Injections: A single mid-sequence harmful injection skyrockets base Llama-3.1-8B's ASR from 0.00% to 92.31% (OM) on AdvBench. After two iterations of trajectory alignment, ASR drops to 4.81% (OM) / 0.00% (LG), outperforming representation-level defenses like Circuit Breakers on out-of-domain benchmarks (where Circuit Breakers leaves >26% ASR on Llama, vs. ≤3.00% for trajectory alignment).
  • Zero-Shot Transfer to Classic Jailbreaks: Although trained only on mid-sequence injections, the defense generalizes to unseen early-token attacks. On Qwen2.5-7B, Prefilling ASR on AdvBench drops from 84.62% to 0.00% (LG), and gradient-based I-GCG suffix attacks on HarmBench drop from 16.25% to 2.81% (LG). Even when forced to start dangerously, the aligned model absorbs the bad prefix and pivots back to refusal within a single sentence.
  • Preserved Utility: General reasoning (MMLU, PROST) stays within 1.1 percentage points of base models, MT-Bench drops by a negligible 0.06–0.11 points, and AlpacaEval win rates slightly increase (+0.32 to +0.84 points).

Limitations and Future Work

While benign task performance holds steady, the authors note a backbone-dependent over-refusal trade-off: false-positive refusals on XSTest slightly decreased on Mistral (-0.4 percentage points), but increased on Llama (+6.4 points) and Qwen (+7.6 points), making those models somewhat more cautious on borderline-looking safe prompts. Explicit directions for future work are not discussed in the paper.

Summary updated

Abstract

Safety-aligned Large Language Models (LLMs) remain vulnerable to interventions during inference that redirect generation toward harmful outputs. Recent work attributes this to shallow safety, where alignment concentrates in the first few output tokens. We show that shallow safety is a special case of a broader inference-time vulnerability, in which short token injections at any generation step can substantially alter subsequent safety behavior. We also find that a model's alignment with refusal directions in its hidden states does not predict its robustness to such injection, revealing that internal state alone does not determine generation behavior under perturbation. To address this, we align models directly on generation trajectories constructed by simulating mid-sequence perturbation, and show that this improves robustness to mid-sequence injection and generalizes to attacks that exploit early-token generation. Our work argues that robust safety alignment requires training on the generation process itself, not only its outputs.
BibTeX
@inproceedings{park2026inference,
  author = {Kyungmin Park and Taesup Kim},
  title = {{Inference-Time Vulnerability Beyond Shallow Safety: Alignment Along Generation Trajectories}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=0hBB2oa8uG},
}
Figure