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

*Hui Zhang, Yachao Yuan, Jiayun Wang, Yuanzhuo Li, Hongtao Wang, Yali Yuan*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/150237) · [OpenReview](https://openreview.net/forum?id=jjuXPhJpD0) · [Open on the map](../papers.html#p150237)

Category: [AI Safety, Security & Alignment](../pcat/16.md) › [Model Protection against Unauthorized Fine-Tuning](../pgroup/5.md) · Type: new method · Keywords: malicious fine-tuning, LLM safety, layer-wise sensitivity, defensive post-processing, dynamic routing, LoRA recovery

Areas: [Safety & Security](../areas/safety.md) › Safe Alignment › Fine-Tuning Safety Alignment

## Summary
SLDR is a post-fine-tuning defense that selectively recovers the most and least safety-sensitive layers and uses dynamic routing to apply a recovery adapter only to potentially malicious queries, thereby reducing harmful outputs while preserving downstream task performance.

## Explained to a 5-year-old
People can change big computer programs a little so they do special jobs. Sometimes someone changes them badly, and the program stops saying "no" to bad things but still works for good things. We have a new way to fix this by looking at different parts of the program. We only change the parts that are most important for safety, and we use a helper that only helps when the program thinks the request might be bad. This keeps the program safe and still useful.

## Explained to a 5-year-old, longer
Big computer programs called language models are trained to answer questions and follow rules. Sometimes people want to make these programs do special tasks, like translate or summarize. They can do this by a process called fine-tuning, which changes a small part of the program. If someone does fine-tuning with bad intentions, the program may stop refusing harmful requests. At the same time, the program can still answer normal requests correctly, which makes the problem hidden. Researchers looked at how different parts of the program react when they are changed. They discovered that some parts make the program safer when changed, some make it less safe, and some have almost no effect. This means safety is not the same for every part; it varies. The new idea uses this discovery to protect the program. It only changes the parts that are most important for safety and the parts that are least important. It also adds a special helper that decides when to use these changes. The helper only activates when the program thinks the request might be harmful. As a result, the program stays safe and still works well for normal tasks. This method works for many different kinds of language models and many different tasks. It also works even when a large part of the fine-tuning is malicious.

## For a technical reader
The paper addresses the risk that malicious fine-tuning can weaken a language model’s safety while preserving its performance on legitimate tasks. It first measures how each transformer layer reacts to scaling, discovering that safety sensitivity can be positive, negative, or neutral. Based on this, the defense trains a lightweight LoRA adapter only on the most and least sensitive layers and routes inference through this adapter only for queries that appear unsafe. This selective recovery and dynamic routing keep the model’s downstream accuracy intact while dramatically lowering harmful outputs. The approach has been evaluated on multiple model families, tasks, and safety benchmarks, showing near-zero harmful scores even under high poisoning rates.

## Problem
Malicious fine-tuning of aligned large language models can erode safety behaviors such as refusal while still achieving good performance on legitimate inputs, making it difficult to trust fine-tuning services.

## Method
The approach measures layer-wise safety sensitivity, identifies the most and least sensitive layers, trains a low-rank adapter only on those layers, and employs representation-based dynamic routing to activate the adapter selectively for queries likely to be malicious.

## Results
The approach reduces the average harmful score on Llama3.1/SST2 from 11.54 to 0.08 while maintaining downstream accuracy, and harmful scores stay near zero even when up to 90% of fine-tuning is malicious.

## Contributions
It reveals signed safety sensitivity across layers, proposes a selective recovery adapter trained only on extreme sensitivity layers, and introduces dynamic routing to apply defenses only to malicious queries, achieving strong safety preservation across multiple models and tasks.

## Practical relevance
This defense enables safer fine-tuning-as-a-service by protecting against malicious attacks while preserving model utility for legitimate tasks.

## Research questions this paper is counted under

- [Why does fine-tuning language models on narrow or benign data cause safety alignment to degrade or shift unexpectedly?](../q/40.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/150237)
