cs.CROct 7, 2026

SLDR: Defending Against Malicious Fine-tuning via Selective Layers Recovery and Dynamic Routing

Authors: Hui Zhang, Yachao Yuan, Jiayun Wang, Yuanzhuo Li, Hongtao Wang, Yali Yuan

Organizations: North China Electric Power University · Southeast University · Soochow University · Engineering Research Center of Intelligent Computing for Complex Energy Systems, Ministry of Education

Abstract

Fine-tuning-as-a-service enables users to adapt aligned large language models (LLMs) to specialized tasks, but malicious fine-tuning can erode refusal behavior while preserving task performance on legitimate inputs. We revisit recent layer-wise safety diagnostics and find that safety sensitivity is signed: scaling different layers can strengthen refusal, weaken it, or have little effect. Motivated by this observation, we propose SLDR, a post-fine-tuning defense based on Selective Layers Recovery and Dynamic Routing. SLDR trains a LoRA recovery adapter only on the layers with the maximum and minimum sensitivity scores in the signed spectrum, and uses representation-based dynamic routing inference to activate the adapter only for malicious queries. Across four model architectures, five downstream tasks, and four harmful benchmarks, SLDR substantially reduces harmful outputs while preserving downstream utility. On Llama3.1/SST2, SLDR reduces the average harmful score from 11.54 to 0.08 while maintaining downstream accuracy, and the harmful score remains near zero under poisoning ratios up to 0.9. The code is available at https://github.com/Stardust457/SLDR.

Figures & tables

Appendix figures & tables16 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. HyperSafe: Inference-Time Safety Recovery for Fine-Tuned Language Models

    Jul 13, 2026Aznaur Aliev, Carlos Hinojosa, Abdelrahman Eldesokey +3LLM Fine-TuningLLM Safety Alignment

  2. Jailbreak to Protect: Buffering and Reinforcing via Temporary Jailbreaking for Safe Fine-Tuning in Large Language Models

    May 23, 2026Seokil Ham, Jaehyuk Jang, Wonjun Lee +1LLM Fine-TuningLLM Safety Alignment

  3. When Safety Routing Breaks: Understanding Alignment Fragility under Benign Fine-Tuning

    Sep 1, 2026Yitong Guo, Xiaoyi Chen, Siyuan Zhang +2LLM Fine-TuningLLM Safety Alignment