Skip to content

REFLECTOR: Internalizing Step-by-Step Reflection to Defend Against LLM Indirect JailbreakREFLECTOR: Internalizing Step-wise Reflection against Indirect Jailbreak

arXiv· arXiv:2605.20654· Jiachen Ma, Jiawen Zhang, Xiangtian Li, Bo Zou, Chaochao Lu, Chao YangFudan University; Shanghai Artificial Intelligence Laboratory; Zhejiang UniversityIndexed by this site · 25 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose a two-stage defense framework, REFLECTOR, which on Llama-3.1-8B raises DSR against four types of indirect jailbreaks from 8.65%–10.04% to above 90%.

Threat modelDefender perspective: the attacker uses indirect jailbreaks (DRA, PAP, ReNeLLM, DrAttack) to hide malicious intent in multi-step reasoning tasks, and the model produces harmful content only after generating 20 tokens, bypassing surface alignment; the victim systems are the open-source instruction models Llama-3.1-8B-Instruct and Qwen-2.5-7B-Instruct; the defense goal is to dynamically intercept risk within the reasoning trajectory and switch to refusal.

Questions
Indirect jailbreaks hide malicious intent inside multi-step reasoning tasks, with harmful content appearing only after 20 tokens are generated, bypassing surface-level alignment that looks only at the input or prefix; existing methods guard the "entrance" of generation but do not protect the reasoning process.
Methods
The authors propose a two-stage framework, REFLECTOR: first use GPT-5 as teacher to generate trajectories with reflection markers for SFT, injecting "search-recover"-style reflection capability; then use GDPO reinforcement learning, with a dual reward of safety reward plus reflection reward, to internalize reflection into the model parameters.
Experiments and results
On Llama-3.1-8B and Qwen-2.5-7B, DSR exceeds 90% on all four types of indirect jailbreaks, reaching 100% on XsTest; GSM8K improves by 5.65 percentage points to 90.15%; DSR against ICL jailbreak, AutoDAN-Turbo, and multi-turn ActorAttack is 81.0%, 90.0%, and 91.0%, respectively.
Limitations and future work
The authors do not specifically discuss limitations in Limitations; the experiments cover only two 7B–8B open-source models, the training data are based on BeaverTails and AlpacaEval, safety judgment relies on the consensus of the HarmBench classifier and GPT-OSS-120B, and the paper does not report human evaluation agreement.
Experimental setupLLaMA-3.1-8B-Instruct、Qwen-2.5-7B-Instruct · StrongREJECT、XsTest et al. · DSR、Goodness Score et al.
Evaluated models
LLaMA-3.1-8B-InstructQwen-2.5-7B-Instruct
Benchmarks
StrongREJECTXsTestWildChatDo-Not-AnswerAdvBench (AutoDAN, GCG, PAIR)AdvBench (DRA, PAP, ReNeLLM, DrAttack)MMLU-ProGSM8KSimpleQAAdvGLUEHarmBench (I-FSJ)AutoDAN-TurboActorAttack
Metrics
DSRGoodness ScoreMulti-choice AccuracyEM / F1Task Accuracy
AI summaryThe two-stage framework REFLECTOR internalizes step-by-step reflection into LLM generation trajectories, achieving a defense success rate of over 90% against complex indirect jailbreak attacks. It first uses teacher-guided generation of reflection data for SFT, then trains autonomous reflection with RL supervised by outcome-driven and reward-validity signals, and can generalize to a variety of threat scenarios. It brings a 5.85% improvement on GSM8K, also improves knowledge-intensive benchmarks, and does not significantly increase computational overhead.

The two-stage framework REFLECTOR internalizes step-by-step reflection into LLM generation trajectories, achieving a defense success rate of over 90% against complex indirect jailbreak attacks. It first uses teacher-guided generation of reflection data for SFT, then trains autonomous reflection with RL supervised by outcome-driven and reward-validity signals, and can generalize to a variety of threat scenarios. It brings a 5.85% improvement on GSM8K, also improves knowledge-intensive benchmarks, and does not significantly increase computational overhead.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Indirect jailbreaks hide harmful content in the middle of reasoning, bypassing surface-level alignment; the authors propose a defense that internalizes step-wise reflection into the generation trajectory.

    Core problem: indirect jailbreak attacks hide malicious intent in multi-step reasoning tasks, causing the model to produce harmful content only after generating 20 tokens, thereby bypassing surface-level safety alignment that only checks the input or the response prefix.

    • Problem scenario: the authors state that indirect jailbreaks such as DRA, DrAttack, and ReNeLLM disguise harmful requests as puzzle-solving or structured tasks, inducing the model to reconstruct the malicious goal itself during reasoning; Figure 1 shows that harmful tokens in direct jailbreaks appear immediately, whereas in indirect attacks they appear only after 20 tokens, which the authors state makes their ASR higher than that of direct attacks.
    • Shortcomings of existing methods: the authors argue that Shallow Alignment protects only the response entry point, that reasoning-aware methods such as STAIR are bypassed when the attacker controls the reasoning structure itself, that external guardrails (HarmBench classifier, Llama Guard) may miss superficially harmless indirect prompts, and that inference-time reminder-style defenses place instructions outside the policy and may be ignored.
    • Core observation: the authors model response safety as a step-wise property: a trajectory may start safe and become harmful only after the latent intent is reconstructed, so risk must be dynamically intercepted at any intermediate step and the model switched to a refusal state.
    • Proposed approach: the paper proposes the REFLECTOR framework, which internalizes self-reflection into the generation trajectory in two stages—first SFT on teacher-guided generated reflection data to establish a structured reflection pattern, then RL (GDPO) with an outcome safety reward and a reflection-effectiveness reward to consolidate the reflection capability into the parameters.
    • Threat model:
      • Attacker goal: make the model autonomously generate harmful content via indirect jailbreaks, with DRA, PAP, ReNeLLM, and DrAttack as representatives in the paper.
      • Attacker knowledge/capability: the paper does not explicitly define a white-box or black-box setting; the attacker controls the structure of the reasoning process (reconstruction rules or in-context examples).
      • Victim systems: open-source instruction models Llama-3.1-8B-Instruct and Qwen-2.5-7B-Instruct.
      • Defender setting: the defense is built into the model parameters (training-time defense), and success is judged as giving a harmless (refusal) response to a harmful query, i.e., DSR.
  2. What related research exists?

    Related work falls into four groups: direct/indirect jailbreak attacks, refusal-based alignment, external guardrails and inference-time defenses, and reasoning-aware alignment.

    Jailbreak attacks

    • Direct jailbreaks: GCG (Zou et al., 2023) uses adversarial suffixes, AutoDAN (Liu et al., 2023a) generates stealthy prompts, PAIR (Chao et al., 2025) jailbreaks black-box models within twenty queries, PAP (Zeng et al., 2024) uses persuasive surface prompts; the authors state that the harmful intent of such attacks is exposed at the prompt boundary or near the response prefix, and most have been mitigated by existing alignment methods.
    • Indirect jailbreaks: DRA (Liu et al., 2024) hides harmful requests behind disguise and reconstruction, DrAttack (Li et al., 2024a) decomposes malicious intent into hard-to-detect fragments, ReNeLLM (Ding et al., 2023) embeds rewritten harmful instructions into natural scenarios; the authors state that such attacks turn reasoning itself into the attack vector, introducing trajectory-level risk.

    Refusal-style alignment

    • RLHF (Ouyang et al., 2022), Safe RLHF (Dai et al., 2023), DPO (Rafailov et al., 2023) provide surface-level defense by recognizing harmful inputs or starting with a standard refusal; the authors hold that they concentrate safety behavior in refusal patterns or early tokens, resulting in shallow alignment.

    External guardrails and inference-time defenses

    • The HarmBench classifier (Mazeika et al., 2024) and Llama Guard (Inan et al., 2023) are practical external guardrails; the authors hold that they may miss superficially harmless indirect prompts, or detect unsafe content only after it has been generated.
    • Inference-time reminders and self-critique prompt defenses (Phan et al., 2025; Wei et al., 2022) require no retraining; the authors hold that safety instructions are external to the policy and may be ignored, diluted, or only superficially followed.

    Reasoning-aware alignment

    • Shallow Alignment (Qi et al., 2024) extends safety guardrails beyond the initial tokens; STAIR (Zhang et al., 2025a) fine-tunes on large-scale CoT data and reinforces safety reasoning with step-wise DPO; the authors hold that when attackers control the reconstruction rules or in-context examples, indirect attacks can still exploit the reasoning process.

    Baselines and benchmarks: the paper's comparison baselines are SFT, DPO, Self-Critique (CoT plus reflection instructions), Shallow-Align, STAIR; safety benchmarks include StrongREJECT, XsTest, WildChat, Do-Not-Answer and direct and indirect attacks on AdvBench, and utility benchmarks are MMLU-Pro, GSM8K, SimpleQA, AdvGLUE.

    The authors position this paper as: no longer treating safety as an external boundary defense, but internalizing step-wise safety as a learnable trajectory-level mechanism into the model policy.

  3. How does the paper address this problem?

    Two stages: SFT on teacher-guided reflection data to inject reflection capability, then GDPO with dual rewards to internalize reflection into the parameters.

    The overall idea is to change safety alignment from "constraining the output prefix" to "constraining the entire generation trajectory", using the REFLECTOR framework to let the model identify risk at any reasoning step, trigger reflection, and switch to a safe refusal.

    Problem Formulation

    • Generation is modeled as a step-wise trajectory, safety is defined as the cumulative validity of the entire trajectory, and the goal is "continuous vigilance": intercepting potential risk at any step yt and immediately switching to a refusal state.
    • The authors point out two challenges: pretrained models lack intrinsic reflection capability, causing an RL cold start; low-quality reflection not only fails to help safety but also disrupts generation, so the model needs to learn when and how to reflect.

    Stage One: SFT Injects Reflection Capability

    • Data construction: for an indirect jailbreak query x, the policy first generates a complete trajectory, a truncation point n ∼ U{1,...,T} is randomly sampled to obtain the prefix y_before; the teacher model (GPT-5) generates a structured reflection segment z = (z_reflect, z_explore) for the truncated context, then generates a continuation y_after ending in a safe state, forming the trajectory τ̃ = (y_before, z, y_after).
    • Special markers: <|reflect|> marks reflection content, <|explore|> marks exploration guidance; Appendix B gives the complete prompt templates for the teacher to generate reflection and safe continuations.
    • Seed data: DRA is used to generate 1,500 indirect attack samples based on BeaverTails (strictly filtered to zero overlap with AdvBench), plus 500 AlpacaEval samples to maintain general instruction capability; all responses are uniformly formatted with the <|reflect|> marker.
    • Effect: SFT makes the model follow the reflection format and establishes the causal mapping "risk identification → trigger reflection", which the authors call a "search-recovery" mechanism, providing initialization for RL.

    Stage Two: Reinforcement Learning with Dual Rewards

    • Algorithm: a variant of GRPO, GDPO (Group reward-Decoupled Normalization Policy Optimization), is adopted; the authors state that under multi-reward settings it normalizes each reward component separately before aggregating, preserving relative differences within components and stabilizing optimization.
    • Sampling and update: G = 8 trajectories are sampled per query, and the policy is updated with group-normalized advantages; the RL stage takes 600 items per category from DR, using only queries and binary safety labels.
    • Dual rewards: the total reward is r(τ) = rsafety(y) + rreflect(z, y), where the safety reward is given by the hybrid evaluator HarmCLS (harmful 0, harmless 1), and the reflection reward is +λ when "there is reflection and the final output is harmless", −λ when "there is reflection but it is still harmful", and 0 when there is no reflection.
    • Safety evaluator HarmCLS: the intersection of the HarmBench classifier (discriminative) and GPT-OSS-120B (generative, with three states Benign/Refusal/Harmful); only when both judge it harmless is it considered harmless; the authors state that this is stricter than keyword prefix matching (Appendix D).
    • Hyperparameters (Appendix C.1): learning rate 1×10⁻⁶, batch size 64, sampling temperature 0.7, top-p 0.95, PPO clip 0.2, KL coefficient 0.001, trained for 1 epoch; reflection reward weight w2 = 0.3 (main experiments λ = 0.3).

    Success Criteria and Evaluation Methods

    • The safety metric is DSR: the proportion of harmful queries for which the model generates a harmless (refusal) response, judged by HarmCLS; StrongREJECT reports goodness score according to the official protocol.
    • Utility metrics: MMLU-Pro multiple-choice accuracy, GSM8K accuracy, the average of EM and F1 on SimpleQA, and AdvGLUE average task accuracy.
  4. What experiments did the paper conduct?

    On both open-source models, DSR for indirect jailbreaks exceeds 90%, GSM8K instead rises by 5.65 percentage points, and adaptive and multi-turn attacks were also tested.

    Experimental Setup

    • Target models: Llama-3.1-8B-Instruct and Qwen-2.5-7B-Instruct; all analysis experiments are conducted on Llama-3.1-8B-Instruct; additionally compared with four reasoning models: LLaMA-o1, Skywork-o1, DeepSeek-r1-Distilled-LLaMA-8B, QwQ-32B-Preview.
    • Safety benchmarks: StrongREJECT (313 items), XsTest (200), WildChat toxicity greater than 0.4 subset (500), Do-Not-Answer (939); direct attacks AutoDAN/GCG/PAIR and indirect attacks DRA/PAP/ReNeLLM/DrAttack are all based on AdvBench (520 items each) (Table 8).
    • Baselines: SFT, DPO, Self-Critique, Shallow-Align, STAIR, implemented following the STAIR approach.
    • Metrics and judges: StrongREJECT reports goodness score, the rest report DSR; safety judgment uses HarmCLS (intersection of the HarmBench classifier and GPT-OSS-120B); utility uses MMLU-Pro (14,079 items), GSM8K (1,319), SimpleQA (4,330), AdvGLUE (738).
    • Training data: SFT uses 1,500 indirect attack samples generated by DRA (based on BeaverTails, with zero overlap with AdvBench) plus 500 AlpacaEval; RL takes 600 items per category, G = 8.
    • Number of repetitions: not reported in the paper.

    Main Results

    According to Table 1 (DSR, higher is better; StrongREJECT is goodness score):

    Swipe horizontally to read the table

    MethodStrongREJECTXsTestAutoDANGCGDRAPAPReNeLLMDrAttack
    Llama Original40.54%88.00%94.75%78.40%10.04%38.28%42.70%29.80%
    Llama STAIR87.98%99.00%99.04%86.15%55.83%85.35%77.27%70.31%
    Llama Ours(+GDPO)89.31%100.00%100.00%94.23%92.31%93.65%97.05%95.49%
    Qwen Original39.05%73.50%52.89%40.80%8.65%36.34%40.19%28.84%
    Qwen STAIR84.86%99.00%95.19%87.69%59.81%82.53%78.65%73.07%
    Qwen Ours(+GDPO)86.90%100.00%97.89%95.96%90.38%91.34%94.23%92.50%

    (Rows for SFT, DPO, Self-Critique, Shallow-Align and Ours(+SFT) are omitted; among them, Self-Critique achieves only 15.00%–48.65% on most indirect attacks, lower than Shallow-Align and STAIR.)

    • The authors state that REFLECTOR achieves DSR above 90% on all four types of indirect attacks, reaches 100% on XsTest, and improves over the original model by 8.71 percentage points on WildChat (original source wording; according to the table, from 38.50% to 81.20%).
    • The authors hold that SFT establishes the reflection framework and RL further optimizes the trajectories, and that the combination of the two achieves the best results.
    • Exception: on StrongREJECT, Ours(+GDPO) in the Llama group is 89.31%, higher than STAIR's 87.98%; in the Qwen group it is 86.90%, higher than STAIR's 84.86%, a small gap.

    Adaptive and Stronger Attacks

    • ICL jailbreak (I-FSJ protocol, 100 queries): average DSR rises from 8.5% to 81.0% (Table 9); at 16-shot the base model drops to 0.0%, while REFLECTOR remains at 72.0%, and the reflection trigger rate saturates to 100% at high shot counts (Table 10).
    • Automated strategy search and multi-turn attacks: under AutoDAN-Turbo DSR rises from 5.0% to 90.0%, and under multi-turn ActorAttack (100 items) from 21.0% to 91.0% (Table 11).
    • Reflection marker suppression (adaptive decoding): after setting the logit of <|reflect|> to −∞, WildChat 80.00%, DRA 90.76%, AdvGLUE 67.04%, close to standard decoding (Table 5); the authors state that the correction mechanism has been internalized rather than relying on surface markers.

    Utility and Cost

    • Utility (Table 2, Llama-3.1-8B): GSM8K rises from 84.50% to 90.15% (+5.65 percentage points), MMLU-Pro 45.20%, SimpleQA 6.45%, AdvGLUE 68.29%, all not lower than the original model; the authors state that safety reflection and general capability can mutually reinforce each other. Appendix G notes that the utility improvement is task-dependent: MMLU-Pro is only +0.95.
    • Computational cost (Table 6, average over 500 items per dataset): SFT increases StrongREJECT responses from 295.57 tokens to 391.95, which falls back to 302.58 after RL, with a time of 0.249s close to the original model's 0.235s; the authors state that after RL internalizes reflection the cost is not large.
    • Comparison with reasoning models (Table 7): QwQ-32B-Preview's goodness score under PAIR drops to 0.3195, WildChat DSR 49.60%; Ours(+GDPO) is 0.7665/0.9328 under PAIR/PAP, WildChat 81.20%; the authors state that general reasoning capability alone cannot provide robustness to indirect risks.

    Other Ablations and Analyses

    • Training data source (Table 3): DR is constructed using PAP/ReNeLLM/DrAttack/DRA respectively; on DRA, DSR is 90.58%–92.31%, standard deviation ±0.84%; the authors state that the defense is not tied to a specific attack source.
    • Safety data ratio (Figure 3): the authors state that too much safety data lowers the MMLU score, and a 3:1 safety-to-general data ratio achieves the best trade-off.
    • Necessity of two stages (Table 4): applying GDPO directly to the base model gives DRA 87.88% but AdvGLUE drops by 4.13 percentage points; SFT+GDPO gives 92.31% and AdvGLUE +9.96.
    • Reflection reward coefficient λ (Table 4): at λ=0, DRA drops to 83.65%; at λ=0.8, MMLU-Pro drops to 42.15% and AdvGLUE to 60.03%; the main experiments use λ=0.3.
    • Teacher and reward model (Table 12): replacing the teacher with GPT-3.5-turbo, DRA goes from 92.31% to 90.85%; replacing the reward model with Qwen-Guard, DRA is 89.40%.
    • Judge model sensitivity (Table 13): re-judging with GPT-OSS-20B, RISE-Judge-Qwen2.5-7B, LLaMA-3.1-8B-Instruct, indirect jailbreak DSR is 94.63%–99.15%, with GPT-OSS-120B giving the lowest scores.
  5. What are some points that can be further explored?

    The authors do not specifically discuss limitations; the experiments cover two 7B–8B open-source models, and safety judgment relies on the consensus of a classifier and a generative judge.

    Limitations and Future Directions Noted by the Authors

    • The paper does not set up a Limitations section specifically discussing limitations.
    • Appendix G notes: the utility improvement is task-dependent rather than universal—the improvement is concentrated in tasks requiring intermediate checking and correction (GSM8K, AdvGLUE, SimpleQA), while fixed-format knowledge tasks such as MMLU-Pro change only marginally (+0.95); the authors explicitly caution that this effect should not be interpreted as a consistent gain across all benchmarks.
    • Appendix D.1 notes that keyword prefix matching evaluation has false positives and cannot detect partial compliance; this is the authors' motivation for adopting a hybrid evaluator, not a statement of limitations of their own method.

    Scope of Experimental Coverage

    • The target models are two open-source instruction models, Llama-3.1-8B-Instruct and Qwen-2.5-7B-Instruct; the comparison reasoning models are LLaMA-o1, Skywork-o1, DeepSeek-r1-Distilled-LLaMA-8B, QwQ-32B-Preview (Table 7).
    • Safety evaluation covers: 4 overtly harmful benchmarks, 3 direct attacks, 4 indirect attacks, plus ICL jailbreak (I-FSJ, 100 items), AutoDAN-Turbo, multi-turn ActorAttack (100 items), and an adaptive decoding test with reflection marker suppression.
    • Training data scale: SFT uses 1,500 indirect attack samples (DRA generated based on BeaverTails) plus 500 AlpacaEval; RL takes 600 items per category, G = 8, trained for 1 epoch.
    • Safety judgment is given by the intersection of the HarmBench classifier and GPT-OSS-120B; the paper does not report the agreement between these automatic judges and human judgment (it only relays the human agreement rate reported in the original HarmBench classifier paper).
    • The paper does not report the number of repetitions or variance of the experiments (Table 3 only gives the standard deviation of the training data source ablation), nor does it report the attacker's iteration budget or number of queries.
  6. Summarize the main content of the paper

    A two-stage defense that internalizes step-wise reflection into the generation trajectory; indirect jailbreak DSR exceeds 90%, and utility does not drop but rises.

    A defense paper: against indirect jailbreaks that hide malicious intent in multi-step reasoning, the authors propose REFLECTOR, which internalizes self-reflection as a trajectory-level safety mechanism into the model parameters.

    • Problem: the authors state that harmful content in indirect attacks appears only after 20 tokens are generated (Figure 1), and that surface alignment guarding only the "entry point" and reasoning-aware methods are both bypassed.
    • Method: stage one uses GPT-5 as teacher to generate "search-recover"-style reflection data with <|reflect|>/<|explore|> markers on randomly truncated trajectories for SFT; stage two uses GDPO reinforcement learning, with a safety reward (HarmCLS: intersection of the HarmBench classifier and GPT-OSS-120B) plus a reflection reward (±λ) as dual signals to consolidate the reflection behavior.
    • Main results: on Llama-3.1-8B, DSR for DRA rises from 10.04% to 92.31%, and on Qwen-2.5-7B from 8.65% to 90.38%; all four types of indirect attacks exceed 90%, and XsTest reaches 100% (Table 1).
    • Utility: GSM8K rises from 84.50% to 90.15%, AdvGLUE 68.29%, and the authors state no "alignment tax" was paid; Appendix G notes that the improvement is concentrated in tasks requiring intermediate checking, with MMLU-Pro only +0.95.
    • Generalization: average DSR for ICL jailbreaks is 81.0% (still 72.0% at 16-shot), AutoDAN-Turbo 90.0%, multi-turn ActorAttack 91.0%; suppressing the reflection markers leaves performance essentially unchanged, which the authors state shows the mechanism has been internalized.
    • Authors' conclusion: safety and general intelligence can mutually reinforce each other, and REFLECTOR provides an "always-on" trajectory-level defense at modest computational cost; the authors have released code and data.

Related papers

Show 3 more papers
Read originalarxiv.org