Safe-FedLLM: Delving into the Safety of Federated Large Language Models

Mingxiang Tao, Yu Tian, Wenxuan Tu, Yue Yang, Xue Yang, Xiangyan Tang

TL;DR

Safe-FedLLM is a novel defense framework designed to protect Federated Learning (FL) for Large Language Models against malicious clients. By treating Low-Rank Adaptation (LoRA) weight updates as high-dimensional "behavioral features," the system uses a lightweight probe to identify and filter out harmful updates at the step, client, and shadow levels, significantly improving model safety with negligible overhead.

What Problem Does This Paper Address?

Federated Learning is a go-to solution for training LLMs on private, distributed data. However, the very privacy it provides—data invisibility—creates a massive security loophole. Malicious participants can inject "poisoned" updates or backdoors into the global model, and because the server never sees the raw data, these attacks are hard to catch.

Traditional defenses (like robust aggregation) were built for smaller models and often fail when applied to the high-dimensional, structured updates used in parameter-efficient fine-tuning (PEFT) like LoRA. The authors identify a critical gap: how can we identify malicious behavior solely by looking at the mathematical changes in model weights?

Methods

The authors propose Safe-FedLLM, which centers on a component called the LoRA-Probe.

  1. LoRA-Probe: This is a lightweight linear classifier (logistic regression) trained offline. It learns to distinguish between "benign" weight changes (from normal instruction tuning) and "malicious" weight changes (from harmful data).
  2. Multi-Level Defense:
    • Step-Level: Monitors updates at every local training step using Bayesian statistics to down-weight suspicious clients gradually.
  3. Client-Level: Evaluates the total weight change at the end of a round and applies a "security factor" to the update before aggregation.
  4. Shadow-Level: This is the most robust variant. It maintains a separate "shadow" LoRA branch that is decoupled from the main training. This shadow branch provides a stable reference point for the probe, preventing the detection accuracy from dropping as the main model evolves (a phenomenon known as distribution drift).
  5. Security-Weighted Aggregation: Instead of a simple average (FedAvg), the server uses the probe's scores to skip rounds dominated by attackers or to weigh honest updates more heavily.

Datasets

The study utilizes several prominent datasets to simulate a realistic federated environment:

  • Benign Data: LMSYS-Chat and WildChat (real-world user-assistant interactions).
  • Malicious Data: BeaverTails (safety-aligned prompts/responses) and MaliciousGen (automatically generated harmful content).
  • Evaluation Benchmarks: AdvBench for safety (using metrics like Rule-based matching, MD-Judge, and Reward Models) and MT-Bench (specifically the first-turn MT-1 score) to ensure the model's general utility isn't sacrificed.

Key Insights and Ideas

  • Weights as Behavioral Fingerprints: The core "aha moment" is that malicious intent leaves a distinct signature in the LoRA weight space. Even without seeing the text, the way the weights shift when learning harmful content is mathematically separable from how they shift when learning helpful content.
  • The Vulnerability of FedAvg: Preliminary experiments showed that even if only 20% of clients are malicious, the safety of a standard Federated LLM collapses.
  • Solving Distribution Drift: In many defenses, as the model gets smarter, "normal" updates start looking different, causing the defense to fail. The Shadow-Level approach solves this by using a fixed reference branch, ensuring the "security signal" remains clear throughout the entire training process.

Key Results

  • Superior Safety: On the Llama3.1-8B backbone, Safe-FedLLM (Shadow-Level) outperformed the best existing baseline (Krum) by 52.7% on the "Rule" safety metric.
  • No Utility Trade-off: Unlike many security measures that make models "dumber" or more restrictive, Safe-FedLLM maintained (and in some cases improved) the model's performance on benign tasks, as measured by MT-Bench.
  • High Efficiency: The framework is incredibly lightweight. The Step and Client levels add no extra parameters, and even the Shadow-Level (which doubles LoRA parameters) only increases total training time by about 3.2% because the branches can be computed in parallel.
  • Robustness: The system remained effective even when the ratio of malicious clients reached 50%.

Limitations and Future Work

The authors acknowledge a few hurdles for real-world deployment:

  • Initialization Dependency: The current framework assumes the server and clients share a random seed for LoRA initialization, which might be hard to guarantee in completely open environments.
  • Transferability: A probe trained for one model (e.g., Llama) doesn't necessarily work for another (e.g., Qwen). Future work is needed to create "cross-backbone" probes.
  • Long-term Drift: While the Shadow-Level helps, extremely long training runs might still see a degradation in probe reliability as the global model moves further away from the initial state.

Future research will likely focus on making these probes more "plug-and-play" across different model architectures and relaxing the requirements for synchronized initialization.

Summary updated

Abstract

Federated learning (FL) addresses data privacy and silo issues in large language models (LLMs). Most prior work focuses on improving the training efficiency of federated LLMs. However, security in open environments is overlooked, particularly defenses against malicious clients. To investigate the safety of LLMs during FL, we conduct preliminary experiments to analyze potential attack surfaces and defensible characteristics from the perspective of Low-Rank Adaptation (LoRA) weights. We find two key properties of FL: 1) LLMs are vulnerable to attacks from malicious clients in FL, and 2) LoRA weights exhibit distinct behavioral patterns that can be filtered through simple classifiers. Based on these properties, we propose Safe-FedLLM, a probe-based defense framework for federated LLMs, constructing defenses across three dimensions: Step-Level, Client-Level, and Shadow-Level. The core concept of Safe-FedLLM is to perform probe-based discrimination on the LoRA weights locally trained by each client during FL, treating them as high-dimensional behavioral features and using lightweight classification models to determine whether they possess malicious attributes. Extensive experiments demonstrate that Safe-FedLLM effectively enhances the defense capability of federated LLMs without compromising performance on benign data. Notably, our method effectively suppresses malicious data impact without significant impact on training speed, and remains effective even with many malicious clients. Our code is available at: https://github.com/dmqx/Safe-FedLLM.
BibTeX
@misc{tao2026safe,
  author = {Mingxiang Tao and Yu Tian and Wenxuan Tu and Yue Yang and Xue Yang and Xiangyan Tang},
  title = {{Safe-FedLLM: Delving into the Safety of Federated Large Language Models}},
  year = {2026},
  eprint = {2601.07177},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.07177},
}
Figure