FedSecurity: Benchmarking Attacks and Defenses in Federated Learning and Federated LLMs

Shanshan Han, Baturalp Buyukates, Zijian Hu, Han Jin, Weizhao Jin, Lichao Sun, Xiaoyang Wang, Wenxuan Wu, Chulin Xie, Yuhang Yao, Kai Zhang, Qifan Zhang, Yuhui Zhang, Carlee Joe-Wong, Salman Avestimehr, Chaoyang He

TL;DR

FedSecurity is an end-to-end benchmark integrated into the FedML ecosystem, designed to simulate and defend against adversarial attacks in Federated Learning (FL). It provides a standardized framework for evaluating security across diverse models—ranging from simple regressions to Large Language Models (LLMs)—and supports both simulated environments and real-world edge device deployments.

What Problem Does This Paper Address?

Federated Learning (FL) allows multiple clients to train a model collaboratively without sharing their raw data. While this enhances privacy, the decentralized nature of FL opens the door to malicious actors. Adversaries can perform poisoning attacks (submitting "garbage" model updates to prevent convergence or planting backdoors) or reconstruction attacks (inferring private training data from shared gradients).

Despite a flurry of research into these vulnerabilities, the field lacks a unified, standardized benchmark. Most existing studies focus on small-scale models and specific attack types, leaving a significant gap in our understanding of how these threats—and their corresponding defenses—scale to modern architectures like Large Language Models (LLMs). FedSecurity aims to bridge this gap by providing a flexible, extensible toolkit for researchers to test security strategies under a unified setting.

Methods

FedSecurity is built as a supplementary component of the FedML library. It introduces two primary modules:

  • FedAttacker: Injects various attacks at different stages of the FL pipeline.
  • FedDefender: Implements state-of-the-art defensive mechanisms.

The framework categorizes interventions into three stages, as illustrated in the system overview:

Figure 2: FedSecurity overview. FedSecurity enables injecting attacks/defenses (shown in red/green) at various stages of FL at the clients and at the server.
  1. Before-aggregation: Modifying local models at the server before they are combined (e.g., Krum, which filters out outlier models).
  2. On-aggregation: Using robust aggregation functions instead of simple averaging (e.g., Geometric Median or RFA).
  3. After-aggregation: Modifying the final global model to protect it or improve quality (e.g., adding Gaussian noise for differential privacy).

Users can configure these experiments easily via YAML files or direct APIs, allowing for rapid iteration without rewriting core FL training logic.

Figure 1: Examples of attack and defense configurations.

Datasets

The authors evaluate FedSecurity across a diverse set of benchmarks to ensure broad applicability:

  • Computer Vision: CIFAR-10, CIFAR-100, and FEMNIST (using ResNet and CNN architectures).
  • Natural Language Processing: Shakespeare and 20News (using RNNs and BERT).
  • Federated LLMs: PubMedQA (a biomedical research dataset) used to train the Pythia-1B model.
  • Real-world: MNIST for logistic regression on edge devices.

Key Insights and Ideas

  • The "Defense Tax": One of the most critical findings is that nearly all current defense mechanisms degrade model accuracy even when no attack is occurring. For instance, robust aggregators like RFA significantly impact performance compared to standard FedAvg in benign settings. This highlights an urgent need for "detect-then-defend" strategies that only activate when an anomaly is sensed.
  • Byzantine Lethality: Among active attacks, "Byzantine" attacks in random mode—where malicious clients submit updates with arbitrary weights—are the most destructive, effectively preventing the global model from converging.
  • LLM Resilience and Risk: While LLMs are susceptible to backdoors and poisoning, their massive parameter space changes the dynamics of defense. The authors found that $m$-Krum remains effective for LLMs, but defenses requiring the storage of intermediate historical results (like Foolsgold) face significant memory/cache bottlenecks when applied to models with billions of parameters.

Key Results

  • Attack Impact: In head-to-head comparisons, Byzantine random-mode attacks caused the sharpest drop in accuracy across all models. Label-flipping attacks were generally milder but still persistent.
  • Defense Effectiveness: $m$-Krum emerged as a highly effective and versatile defense. In experiments scaling up to 100 clients, $m$-Krum maintained accuracy levels very close to the "no-attack" baseline, even when 10% of clients were malicious.
  • Scalability: The framework was successfully validated on the Theta Network, utilizing 70 real-world edge devices. This demonstrates that FedSecurity isn't just for academic simulations but can handle the latency and connectivity issues inherent in real-world deployments.
Figure 10: RNN (NLP).

Limitations and Future Work

The authors acknowledge two primary limitations:

  1. Synchronous Only: Currently, FedSecurity only supports synchronous FL, where the server waits for a specific number of clients before aggregating. It does not yet support asynchronous FL.
  2. Horizontal Focus: The benchmark is currently tailored for horizontal FL (where clients share the same feature space but different samples) and does not yet cover vertical FL (where clients share the same samples but different features).

Future work involves expanding the library to include these missing FL paradigms and inviting the community to contribute new, novel attack and defense strategies to the open-source repository.

Summary updated

BibTeX
@inproceedings{han2024fedsecurity,
  author = {Shanshan Han and Baturalp Buyukates and Zijian Hu and Han Jin and Weizhao Jin and Lichao Sun and Xiaoyang Wang and Wenxuan Wu and Chulin Xie and Yuhang Yao and Kai Zhang and Qifan Zhang and Yuhui Zhang and Carlee Joe-Wong and Salman Avestimehr and Chaoyang He},
  title = {{FedSecurity: Benchmarking Attacks and Defenses in Federated Learning and Federated LLMs}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2024},
  doi = {10.1145/3637528.3671545},
}
Figure