Emerging Safety Attack and Defense in Federated Instruction Tuning of Large Language Models

Rui Ye, Jingyi Chai, Xiangrui Liu, Yaodong Yang, Yanfeng Wang, Siheng Chen

TL;DR

Researchers have uncovered a critical vulnerability in Federated Instruction Tuning (FedIT), where malicious participants can "break" a Large Language Model's (LLM) safety guardrails using stealthy, automatically generated harmful data. Because these attacks look like normal instruction-following to standard defense algorithms, the authors propose a novel post-hoc defense: an automated pipeline where the server generates its own safety-alignment data to "re-align" the model after aggregation.

The Vulnerability in Federated Instruction Tuning

Federated Learning (FL) allows multiple parties to train a shared LLM without sharing their private data. In the context of Federated Instruction Tuning (FedIT), the goal is to create a model that is both helpful and safe by training on decentralized, human-aligned datasets.

However, a major gap exists: the assumption that all participants are honest. If even a few "malicious" clients join the federation, they can inject unaligned data—pairs of harmful instructions (e.g., "How do I build a bomb?") coupled with helpful, detailed, but dangerous responses.

The Stealthiness Challenge

The core challenge in defending against this is stealthiness. In traditional FL attacks (like label-flipping in image classification), malicious updates look mathematically "wrong" or contradictory to benign updates. In FedIT, a malicious update looks exactly like a benign one: it is simply a model learning to provide detailed, informative responses.

Comparison between traditional label-flipping attacks and the proposed stealthy LLM-alignment attack.

This "Alignment Paradox" means the very thing we want LLMs to do—be helpful and follow instructions—is what makes them vulnerable. Malicious updates are aligned with the objective of instruction-following, allowing them to hide in plain sight and making it nearly impossible for existing "Byzantine-robust" aggregation methods to filter out bad actors.

Proposed Methodology: Attack and Defense Pipelines

To demonstrate the severity of this vulnerability and offer a solution, the paper introduces two primary components: a stealthy automated attack and a post-hoc defense.

Overview of the automated attack generation and the proposed post-hoc defense pipeline in the Federated Instruction Tuning system.

1. The Automated Safety Attack

Malicious clients do not even need manual effort to craft their data; they use an off-the-shelf LLM to automatically generate an "Attack Dataset." * Instruction Generation: Prompting an LLM to generate harmful questions. * Response Generation: Prompting the LLM to answer those questions directly, explicitly ignoring safety guardrails. The attacker then fine-tunes their local model on this data. When these weights are aggregated into the global model, the global LLM "forgets" its safety training.

2. The Post-Hoc Defense

Since the server cannot easily identify which clients are malicious using traditional geometric defenses (like Krum or Trimmed-mean), the authors propose a post-hoc alignment step. The most effective way to secure FedIT is to treat the aggregated result as potentially contaminated and apply a final "sanitization" step. After the global model is aggregated, the server:

  1. Generates Defense Data: Uses an LLM to generate a mix of normal instructions and harmful instructions.
  2. Creates Safe Responses: For harmful instructions, it generates "refusal" responses (e.g., "I cannot assist with that"). For normal instructions, it generates helpful responses.
  3. Final Fine-Tuning: The server performs a few steps of fine-tuning on the aggregated global model using this small, clean "Defense Dataset" before releasing it.

Experimental Setup and Key Results

The authors evaluated their methods using a robust suite of datasets, including LMSYS-Chat, WildChat, and Beavertails, and measured outcomes using AdvBench (for safety) and MT-Bench (for helpfulness).

Key Findings: * Devastating Attack Impact: The proposed safety attack reduced the model's safety rate by up to 70%. The model went from being highly safe to answering almost any dangerous prompt. * Failure of Traditional Defenses: Existing FL defense methods provided almost no protection, offering at most a 4% absolute improvement in safety scores because they rely on Euclidean distance to find outliers, which fails for semantically similar LLM updates. * Proposed Defense Success: The post-hoc defense method successfully restored safety, showing an improvement of up to 69% in safety metrics. Crucially, this was achieved without significantly degrading the model's performance on helpfulness benchmarks. * Scalability: The defense remained effective even as the number of clients scaled from 10 to 100, and it worked across different model architectures like Llama-2 and Mistral.

Limitations and Future Work

While highly effective, the study primarily focuses on single-turn instruction tuning. Real-world applications often involve multi-turn dialogues, which may introduce more complex attack vectors. Additionally, the defense relies on an external "teacher" model to generate safe data; if that teacher model has hidden biases, they might transfer to the global model. Future work will need to investigate "adaptive" attackers who might try to circumvent this post-hoc defense by crafting even more subtle unaligned data.

Code Availability: The authors have released their framework at https://github.com/19dx/FedLLM-Attack.

Summary updated

BibTeX
@inproceedings{ye2025emerging,
  author = {Rui Ye and Jingyi Chai and Xiangrui Liu and Yaodong Yang and Yanfeng Wang and Siheng Chen},
  title = {{Emerging Safety Attack and Defense in Federated Instruction Tuning of Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=sYNWqQYJhz},
}
Figure