Sparse Models, Sparse Safety: Unsafe Routing in MoE Large Language ModelsSparse Models, Sparse Safety: Unsafe Routes in Mixture-of-Experts LLMs
The authors used RoSais and F-SOUR to search for unsafe routes in MoE, with F-SOUR achieving an average ASR of 0.90 on JailbreakBench.
Attackers trigger unsafe routes to make MoE produce affirmative unsafe outputs to harmful questions. They can read routing scores at each layer and use masks Φ∈{0,−∞}^K to restrict top-k; no modification of expert weights or training data. Supports per-instance and universal paths. Appendix G states the assumption of white-box access to routing scores.
- MoE reduces computation by using routing to activate only some experts, but the authors believe the safety risks of this sparse structure are understudied. The question is: does there exist a routing configuration that, without changing expert weights, turns safe outputs into harmful outputs once enabled.
- RoSais uses the maximum log-probability gain on affirmative tokens after random masking to identify safety-critical layers, then modifies only the expert selections of a few high-scoring layers. F-SOUR continues random masking by token and layer, maximizing the log-probability of harmful targets, and a shadow judge decides whether to accept the answer.
- Across the four MoEs, DeepSeek-V2-Lite on JailbreakBench has an ASR of 0.79 after changing 5 layers of routing to dataset-level paths. F-SOUR's average ASR is 0.90 on JailbreakBench and 0.98 on AdvBench.
- Appendix G states: only one model per family is evaluated; RoSais uses only the log-probability gain of affirmative tokens; masks do not directly adjust scores; S3 and S4 have upper bounds; white-box access to routing scores is required. Appendix E states that disabling routes may harm utility and may be weakened by adaptive attacks.
- Evaluated models
- DeepSeek-V2-LiteMixtral-8x7BOLMoE-1B-7BQwen1.5-MoE-A2.7B
- Benchmarks
- JailbreakBenchAdvBenchTruthfulQAGSM8KBeaverTails
- Metrics
- ASRRoSais
The researchers identify a structural vulnerability in MoE large language models called "unsafe routing": once specific sparse routing configurations are activated, they convert harmful questions that would normally be refused into harmful outputs. The authors first propose the RoSais metric to quantify the importance of each layer's router to safety, finding that safety-critical routers are concentrated in a few layers; on JailbreakBench, masking just 5 routers in DeepSeek-V2-Lite raises the attack success rate from 0.15 to 0.79, an increase of more than 4 times. They then propose the F-SOUR framework, which progressively searches for specific unsafe routes by token and layer, achieving average attack success rates of 0.90 and 0.98 on JailbreakBench and AdvBench respectively across four MoE model families: DeepSeek-V2-Lite, Mixtral-8x7B, OLMoE-1B-7B, and Qwen1.5-MoE-A2.7B.
Why it was selectedThe paper treats MoE routing selection itself as an attack surface, provides a reproducible routing manipulation method, and offers a new dimension for safety evaluation of open-source MoE models.
Paper analysis
What problem does this paper attempt to solve?
The authors aim to confirm whether there exists an MoE routing configuration that can turn safe outputs into harmful outputs.
Is MoE safety also sparse with routing: The authors aim to confirm whether there exists a class of routing configurations that, once enabled, turn safe outputs into harmful outputs, referred to as unsafe routes.
- Scenario: MoE uses routing in Transformer layers to activate only a subset of experts (e.g., DeepSeek-V2-Lite selects 6 out of 64), reducing training and inference costs, and is adopted by recent frontier LLMs. The authors argue that misuse risk increases accordingly, such as using the model to generate dangerous medical advice.
- Limitations of prior work: The authors state that previous work mainly focused on utility and efficiency. SAFEx and SteerMoE, while analyzing expert-level safety sensitivity, are diagnostic, rely on pre-existing unsafe or jailbreak data, do not explicitly search routing combinations, and achieve limited safety improvements.
- Core observation: The authors claim that without prior data, defining a route as a sequence of top-k expert selections across layers and actively searching can discover unsafe paths; manipulating only high-RoSais routes can flip the default path into an unsafe one. The abstract states that masking 5 routes increases ASR by over 4 times to 0.79; this number corresponds to the dataset-level in Table 1.
- Contributions: RoSais quantifies the safety importance of each layer's routing; F-SOUR searches for specific unsafe routes token-wise and layer-wise. The authors also list two defense directions: disabling paths at inference and routing training during training.
- Threat model:
- Goal: Given an MoE LLM θ, trigger unsafe routes for harmful questions to increase the likelihood of affirmative (non-refusal) unsafe outputs.
- Knowledge: Can submit arbitrary queries and read routing scores at each layer. Appendix G states the method assumes white-box access to routing scores.
- Capabilities: Apply token- or layer-specific masks at inference, with values 0 or −∞, to restrict top-k expert selection; no modification of expert weights or training data. Paths can be per-instance or universal.
- Victim systems: Representative models from four MoE families. Main evaluation uses ASR to determine if outputs are harmful.
What related research exists?
The authors distinguish this work from MoE safety analyses that rely on prior data and only diagnose expert activations.
Dense and sparse architectures
- Dense Transformer: Modern LLMs mostly originate from dense Transformers; each layer uses the same FFN for all inputs, and computation grows quickly when parameters reach the billion scale.
- Sparse MoE: Shazeer et al. (2017) proposed sparse gated MoE. The router selects k experts (k≤K) for each hidden input, and only the selected experts are executed. In this section, the authors only compare dense and sparse, and state that other variants exist but are not elaborated.
- Utility and applications: The authors state that prior work mainly examined MoE's utility, efficiency, and applications in personalized medicine, in-vehicle systems, and personal computing.
Jailbreaks, evaluations, and refusal mechanisms
- Black-box attacks: The authors list prompt engineering and automated black-box methods, including PAIR and TAP, which iteratively construct prompts under limited query budgets.
- White-box attacks and benchmarks: White-box methods include GCG. Standardized evaluations like JailbreakBench organize attack artifacts and judges for comparing different LLMs and settings.
- Internal refusal: The authors relay that refusal can be mediated by internal directions or features (Arditi et al., 2024, and related representation intervention work).
Alignment and deployment-time filtering
- Training-time alignment: RLHF and others reduce harmful outputs in preference alignment by adding safety data, modifying losses, or training mechanisms.
- Deployment-time guardrails: The authors state that LLaMA Guard and others filter harmful inputs or outputs well. The paper does not write these guardrails as direct experimental comparisons with this method; comparisons are in question 4.
MoE expert-level safety
- SAFEx (Lai et al., 2025): Uses stability-based selection to identify safety-critical experts.
- SteerMoE (Fayyaz et al., 2025): Compares expert activations between prior safe and unsafe modes, then activates or deactivates behavior-related experts.
- Authors' criticism: Both rely on observation rather than active search, are constrained by predefined dataset coverage, usually bring limited harmful output changes, and require prior data.
Baseline methods and benchmarks/datasets: Compare GCG, SHIPS, SAFEx, SteerMoE (classified by the authors as white-box) and TAP (black-box). Harmful queries come from JailbreakBench and AdvBench; AdvBench uses the subset from Chao et al. (2025). SHIPS is a reference for sensitivity importance metrics in the main text and serves as an attention head intervention baseline.
The authors position this work as not requiring prior data, searching route selections rather than only diagnosing activation differences, and optimizing cross-token route sequences rather than only changing expert sets. The introduction also states that existing jailbreaks mostly manipulate inputs or internal weights, while routes are an additional structural degree of freedom in MoE.
How does the paper address this problem?
RoSais measures the safety importance of routing across layers, and F-SOUR searches for specific paths by token and layer.
The overall approach is in two stages: first use RoSais to assign safety importance to each layer's routing and modify a few high-scoring layers; then use F-SOUR to randomly mask by token and by layer, searching for specific unsafe routes without changing expert weights.
Routing and scores
- Object: A route is the sequence of top-k expert selections given by the L-layer router. An unsafe route refers to a configuration that, when applied to a harmful question, increases the log-likelihood of unsafe outputs.
- RoSais: For a harmful question Q, compare the maximum log-probability over the affirmative token set T_aff between no mask and random mask. Defined as RoSais(θ,Q,Rl,S1)=maxs∈[S1][p(s)θ(Taff,Q,Rl)−pθ(Taff,Q)], i.e., the maximum increase from random masking at that layer. Routes with higher scores are considered more safety-critical by the authors.
- Mask: In Φ, exactly k positions are 0 and the rest are −∞, then added element-wise to routing scores, so Top-k can only fall on unmasked experts. The authors use DeepSeek-V2-Lite's 64-choose-6 as an example, with 74,974,368 combinations, claiming exhaustive search is infeasible.
- Affirmative tokens: Appendix A lists affirmative words at the word level, then maps them to each model's tokenizer, keeping only words that correspond to exactly one token.
RoSais path construction
- Estimation and selection: S1=20 random masks per layer. Take the top-LΦ layers by RoSais descending, with LΦ∈{1,2,5}. For each layer, draw S2=100 masks and keep the mask with the largest affirmative probability gain.
- Two-level paths: sample-level constructs a path for each question individually. dataset-level first averages RoSais over the full dataset, then obtains a universal path shared by all questions.
- Expert grouping: unselected experts, experts selected by the default route, and experts activated only after masking. The authors state that masking changes inputs to subsequent layers, so later default selections may also be indirectly affected.
- Known limitations: The authors state that shallow-layer modifications make deep-layer masks selected by the original RoSais no longer optimal; the static, next-token-only approach ignores few-token-depth alignment and token-level routing changes. Fine-grained search is left to F-SOUR.
F-SOUR
- Objective: Given a harmful question Q and a harmful target token sequence A, find a route such that the manipulated model maximizes log Prθ′(A∣ Q). Expert weights remain unchanged.
- Search: Proceed token by token from front to back, and for each token, from layer 1 to layer L. At each position, draw random masks; if the target log-probability improves, write it into the current path.
- Stopping: Each token–layer pair has at most S3=10 trials; threshold τ=log(0.8). If the trial count is not reached and the new probability is below τ, continue sampling; if τ is reached, or the last layer of the last token is reached, generate answer G.
- Shadow judge: Uses StrongReject's rubric template, with GPT-4o-mini as the judge model. If judged unsafe, accept G; otherwise restart with a different random seed, with total attempts S4=5. The paper does not write out the specific rubric text in the main body.
Judgment and model conventions
- ASR: The main judgment uses JailbreakBench's judge prompt, implemented by GPT-4o as Unsafe(·), returning 1 or 0 for each question, then averaged over the question set. RoSais uses next-token log-probability, which is not directly equal to ASR.
- Generation settings: Temperature is set to 0. User input uses only each model provider's chat template, with no additional content. Default expert count K and selected count k use each model's published configuration, see Table 10. Shared experts are activated by default and not selected by the router.
What experiments did the paper conduct?
F-SOUR's average JailbreakBench ASR across four models is 0.90, higher than the listed baselines in the table.
Experimental Setup
- Models tested: DeepSeek-V2-Lite (K=64, k=6, 2 shared experts), Mixtral-8x7B (K=8, k=2), OLMoE-1B-7B (K=64, k=8), Qwen1.5-MoE-A2.7B (K=60, k=4, 4 shared experts). Temperature 0.
- Data: JailbreakBench and AdvBench; AdvBench uses the subset from Chao et al. (2025). The paper does not report the number of examples in either set.
- Baselines: GCG (500 steps per prompt, width=64, top-k=64), SHIPS (scale factor=10^{-5}, top-5 sampling, masking 1 attention head), SAFEx (building groups from 500 samples from several benchmarks), SteerMoE (using its provided steering for Mixtral and OLMoE; otherwise sampling from BeaverTails and activating or deactivating 10 experts), TAP (GPT-4o-mini as both attacker and evaluator, branching=4, width=4, depth=10).
- Reviewer: Main ASR uses JailbreakBench's judge prompt and GPT-4o. The shadow judge inside F-SOUR search is GPT-4o-mini. The paper does not report the number of repetitions or agreement between this judge and human judgment.
- RoSais: S1=20, S2=100, LΦ∈{1,2,5}; split into sample-level and dataset-level.
- F-SOUR: S3=10, S4=5, τ=log(0.8).
Main Results
According to Table 2 (JailbreakBench, ASR). Average ASR for columns not listed: GCG 0.46, SHIPS 0.29, SAFEx 0.31, sample-level Top-5 RoSais 0.59.
Swipe horizontally to read the table
Model No manipulation SteerMoE TAP Dataset Top-5 F-SOUR DeepSeek-V2-Lite 0.15 0.66 0.60 0.79 0.94 Mixtral-8x7B 0.40 0.73 0.36 0.68 0.91 OLMoE-1B-7B 0.00 0.14 0.14 0.34 0.86 Qwen1.5-MoE-A2.7B 0.07 0.46 0.77 0.37 0.88 - AdvBench: The authors state the trend is the same. In Table 13, F-SOUR is 1.00, 0.96, 1.00, 0.94, averaging 0.98; the authors state all evaluated models have ASR≥0.94.
- Authors' summary and counterexamples in the table: The authors state F-SOUR exceeds other attacks by 40% to 61%, and state SAFEx and SteerMoE have ASR≤50%. In Table 2's average column, SteerMoE is 0.50, but its DeepSeek-V2-Lite and Mixtral-8x7B cells are above 0.50. On AdvBench, SteerMoE averages 0.55 (Table 13).
- Baselines below no manipulation: SHIPS has JailbreakBench ASR of 0.00 on DeepSeek-V2-Lite, below the no-manipulation 0.15; on AdvBench it is also 0.00, with no manipulation at 0.02 (Table 13). The authors state RoSais is more cost-effective than F-SOUR; the paper does not report F-SOUR's query count or runtime.
RoSais Distribution and Manipulation
- Distribution: The authors state the highest RoSais routes on JailbreakBench concentrate in a few layers (Figure 3). The peaks given in the main text are 8.60 for Mixtral-8x7B and 8.18 for OLMoE-1B-7B, with exp(8.60)≈5.43×10^3 and exp(8.18)≈3.57×10^3. The authors state Mixtral's sample-level highest layers tend to be shallow, OLMoE's in early-to-middle layers, Qwen's toward the front-middle but still sparse, and DeepSeek's appear in the first, last, and several middle layers. On AdvBench, the authors state the pattern is the same (Figure 6); the main text does not give per-model peaks again.
- JailbreakBench (Table 1): No-manipulation average ASR is 0.16. Sample-level modifying only 1 layer averages 0.49; modifying 5 layers gives Mixtral 0.81 and Qwen 0.63, but DeepSeek goes from 0.50 at LΦ=1 to 0.46 at LΦ=5, and OLMoE from 0.51 at LΦ=2 to 0.45 at LΦ=5. Dataset-level modifying 5 layers takes DeepSeek from 0.15 to 0.79; the abstract says over 4×, while Section 3.4 says about 5.3×. The authors attribute the non-monotonicity to the suboptimality of a static one-time ranking.
- AdvBench (Table 12): No-manipulation average is 0.02. Sample-level rises with LΦ, averaging 0.68 at LΦ=5. Dataset-level on DeepSeek is 0.90 at LΦ=5; OLMoE drops from 0.20 at LΦ=1 to 0.14 at LΦ=5.
Defenses and Utility
- PAT and Self-Reminder: Reported only on DeepSeek-V2-Lite (Table 3). The authors state both reduce RoSais substantially, especially dataset-level, with a maximum reduction of 0.80 (AdvBench dataset-level: 0.90 to PAT's 0.10). For F-SOUR, on JailbreakBench PAT goes from 0.94 to 0.90 and Self-Reminder to 0.88; on AdvBench both go from 1.00 to 0.96. The authors state the maximum reduction for F-SOUR is 0.06.
- Disabling unsafe experts: Appendix E on DeepSeek-V2-Lite takes dataset-level, LΦ=5 paths, disables k=6 experts per layer across 5 layers, then evaluates GCG and TAP (Table 8). On JailbreakBench, GCG goes from 0.38 to 0.02 and TAP from 0.60 to 0.44; on AdvBench, GCG from 0.54 to 0.34 and TAP from 0.66 to 0.52. The authors state this masks only 6/64 experts in each of 5/25 MoE layers.
- Utility: Appendix F, Table 9, still on DeepSeek-V2-Lite. Without manipulation, TruthfulQA is 0.9988/0.8213 and GSM8K accuracy is 0.5610. The authors state that after attack or defense, informativeness and truthfulness generally drop by no more than 0.03. GSM8K, when modifying 1 to 2 layers, is stated by the authors to be unchanged or slightly higher (JailbreakBench, LΦ=1 is 0.5876); when modifying 5 layers, attacks give 0.3351 and 0.3078, and defenses give 0.5216 and 0.5064. The authors state math tasks are more sensitive to routing choices.
Other Ablations and Analyses
- Random masking control (Table 5, DeepSeek-V2-Lite only): On JailbreakBench, random masking ASR is at most 0.24, with dataset-level LΦ=5 at 0.79; on AdvBench, random masking is at most 0.20, with dataset-level LΦ=5 at 0.90.
- Cross-dataset (Table 6, dataset-level): Using paths from the other dataset, JailbreakBench LΦ=5 goes from 0.79 to 0.69; AdvBench LΦ=5 from 0.90 to 0.86; the largest drop is AdvBench LΦ=2 at 0.16.
- S3 (Figure 5a, DeepSeek-V2-Lite): JailbreakBench ASR at S3=5/10/15/20 is 0.92, 0.94, 0.90, 0.93; AdvBench is 1.00 for S3≥10.
- S4 (Figure 5b, same model): From 1 to 5, JailbreakBench goes from 0.85 to 0.94, and AdvBench from 0.90 to 1.00.
- Runtime (Table 7, S1=20, S2=100, LΦ=1, A100-SXM4-80GB): Average per sample ranges from 94.50 seconds (OLMoE-1B-7B) to 528.21 seconds (Mixtral-8x7B).
- The authors state that safety-critical layers on AdvBench are also concentrated in a few layers (Figure 6). Table 14 compares responses before and after F-SOUR, with harmful details redacted in the table.
What are some points that can be further explored?
Appendix G states that only one model per family was evaluated, and assumes white-box access to routing scores.
Limitations and future directions noted by the authors
- Model scope: Due to computational constraints, only one representative model per MoE family was evaluated, not all versions; Appendix C discusses scalability. Future work aims to expand to more and larger MoE LLMs (Appendix G).
- RoSais signal: Uses the maximum log-probability gain on the affirmative token, rather than also suppressing refusal tokens or directly optimizing the answer objective. The authors believe richer multi-objective or objective-aware variants are worth exploring (Appendix G).
- Manipulation form: Masks routing scores before Top-k, without directly adjusting scores. The authors believe this may underestimate the full attack surface, such as gradient guidance (Appendix G).
- Search budget: F-SOUR's random trials S3 and attempts S4 have upper bounds. Ablations show that larger or adaptive budgets might find better unsafe paths; future work considers adaptive budgets (Appendix G).
- Access assumption: The method assumes white-box access to routing scores, which the authors believe may limit applicability to closed APIs. The authors also state that studying MoE structural safety itself requires inspecting internal routing states (Appendix G).
- Defenses and domains: Appendix E states that disabling routing is lightweight and effective, but may sacrifice utility and could be weakened by adaptive attacks; combining with training-time safety coverage and routing regularization is written as next steps. Appendix G's future work also includes finer-grained routing manipulation, safety-aware router training, route auditing, randomized or hardened routing, and extension to hallucination and bias.
Experimental coverage
- Tested models are DeepSeek-V2-Lite, Mixtral-8x7B, OLMoE-1B-7B, Qwen1.5-MoE-A2.7B, totaling 4. Compared methods are GCG, SHIPS, SAFEx, SteerMoE, TAP (Section 4.2, Appendix B).
- Harmful queries come from JailbreakBench and AdvBench (the latter being a subset from Chao et al. 2025). The main ASR is judged by GPT-4o using JailbreakBench's judge prompt. The paper does not report the number of entries, repetitions, or agreement between this judge and human judgment.
- RoSais reports sample-level and dataset-level, with LΦ∈{1,2,5}; random mask control, cross-dataset transfer, and time costs are written on DeepSeek-V2-Lite (Appendix C, Tables 5–7).
- Defense numbers come from PAT and Self-Reminder on DeepSeek-V2-Lite (Table 3), and evaluation of GCG and TAP after disabling dataset-level unsafe experts (Table 8). Utility is TruthfulQA and GSM8K on the same model (Table 9).
- F-SOUR's S3 and S4 ablations are reported on DeepSeek-V2-Lite (Figure 5). The paper does not report F-SOUR's query count or wall-clock time.
Summarize the main content of the paper
F-SOUR's average ASR across the four MoE families is 0.90 (JailbreakBench) and 0.98 (AdvBench).
The authors investigate whether sparse routing in MoE LLMs constitutes an independent security weakness: without changing expert weights, can altering only the top-k expert selection at each layer turn refusals to harmful questions into harmful outputs? Such configurations are called unsafe routes.
Attackers can query arbitrarily and read routing scores at each layer; at inference, masks with values 0 or −∞ restrict top-k. Appendix G states this is white-box access. Paths can be per-instance or shared across the entire dataset.
RoSais measures each layer's routing importance using the maximum increase in log-probability of affirmative tokens after random masking. High-scoring routes are then replaced with the mask yielding the greatest gain, with LΦ taking values 1, 2, or 5. F-SOUR goes beyond a single layer ranking, continuing random masking token-wise and layer-wise to maximize the log-probability of harmful target sequences; GPT-4o-mini serves as a shadow judge, with up to 5 attempts. The main ASR is additionally judged by GPT-4o using JailbreakBench's judge prompt.
The four representative models are DeepSeek-V2-Lite, Mixtral-8x7B, OLMoE-1B-7B, and Qwen1.5-MoE-A2.7B.
- On JailbreakBench, DeepSeek-V2-Lite's dataset-level path with 5 layers changed increases ASR from 0.15 to 0.79 (Table 1). The abstract states over 4 times, while Section 3.4 states approximately 5.3 times.
- On the same benchmark, F-SOUR achieves 0.94, 0.91, 0.86, 0.88, averaging 0.90 (Table 2). On AdvBench, F-SOUR averages 0.98, with all four models at least 0.94 (Table 13).
- The authors state that existing MoE-specific methods have ASR ≤ 50%. In Table 2, SteerMoE averages 0.50, but DeepSeek-V2-Lite is 0.66 and Mixtral-8x7B is 0.73. SHIPS on DeepSeek-V2-Lite is 0.00, lower than the no-manipulation 0.15.
- On DeepSeek-V2-Lite, PAT and Self-Reminder reduce F-SOUR's ASR by at most 0.06 (Table 3). After disabling unsafe experts in 5 layers, GCG on JailbreakBench drops from 0.38 to 0.02 (Table 8).
The authors conclude that routing is an attack surface distinct from input modification or weight modification; if safety alignment is concentrated in a few experts, small routing changes can increase harmful outputs. The authors list disabling paths with high RoSais layers and safety-aware routing training as defense directions, hoping both become red-teaming tools for open-source MoEs. Appendix G outlines scope including one model per family, bounded random search, and white-box access to routing scores.
Related papers
Show 3 more papers
- PEVAttacksarXiv