Skip to content
csrzhangPublic

About

[EuroS&P 2026] GDBR: Label Recovery Attack Against Partial Gradient Encryption in Federated Learning

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

GDBR: Label Recovery Attack Against Partial Gradient Encryption in Federated Learning

This paper proposes a label recovery attack against partial gradient encryption in federated learning. This repository contains the source code for the paper.

Quick start

Environment

This project is tested with Python 3.10. The code uses CUDA automatically when it is available, and falls back to CPU otherwise.

The recommended setup is the conda environment:

conda env create -f environment.yml
conda activate gdbr

The repository also includes pyproject.toml for users who prefer uv/pip-style workflows:

uv sync --extra cpu

environment.yml is the primary portable environment file. pyproject.toml is useful for project metadata and lightweight CPU installs; it does not replace the conda file unless you also configure the correct PyTorch wheel index for your platform.

Data

Datasets are downloaded via torchvision. By default this code uses ~/data (expanded to your home directory) and creates dataset-specific subfolders (e.g. ~/data/cifar10, ~/data/svhn).

Some datasets require manual preparation:

  • mnist, fmnist, svhn, cifar10, and cifar100 can be downloaded automatically by torchvision.
  • cinic10, tiny-imagenet, and imagenet should be placed under ~/data/<dataset-name>/ with the folder layout expected by torchvision.datasets.ImageFolder or ImageNet.

Custom experiments (single configuration)

If you want to quickly run a single experiment configuration (no sweep), use main.py.

main.py:

  • samples a batch from a dataset
  • computes gradients of the victim model
  • optionally applies a defense (--defense + --defense_kwargs)
  • runs GDBR recovery and prints true vs recovered label histograms

Example: run main.py from command line

python main.py \
  --data_dir ~/data \
  --download \
  --dataset cifar10 \
  --aux_dataset cifar10 \
  --model vgg16 \
  --batch_size 32 \
  --distribution tgt_imbalanced \
  --attack_init 0.01 0.2 \
  --num_layers 3

Line-by-line explanation of the arguments:

  • python main.py: run the single-configuration entrypoint (arguments are defined in args.py).
  • --data_dir ~/data: where torchvision datasets are stored/downloaded.
  • --download: download supported torchvision datasets if they are not already present.
  • --dataset cifar10: victim task dataset used to sample the attacked batch.
  • --aux_dataset cifar10: auxiliary dataset used to estimate statistics for recovery (same as victim dataset here).
  • --model vgg16: victim model architecture.
  • --batch_size 32: victim batch size (number of samples whose label histogram is recovered).
  • --distribution tgt_imbalanced: how batch labels are sampled (see src.data.batch_loader.get_batch_data).
  • --attack_init 0.01 0.2: initialization range for init_mode=attack (uniform ([0.01, 0.2]) on linear weights).
  • --num_layers 3: number of bottom FC layers used by GDBR (get_bottom_layers).

Tip: you can run the same configuration with multiple trials by adding --num_trials N.

Run experiments (sweeps)

All sweep scripts write JSON outputs under ./results/.

1) Sweep ViT batch sizes

Runs sweep_vit_batch_sizes.py and saves results to results/sweeps/.

./run_sweep_vit_batch_sizes.sh

Or run directly:

python sweep_vit_batch_sizes.py --help

2) Sweep FL local updates (multi-batch SGD)

Runs sweep_fl_local_updates.py and saves results to results/sweeps_local_update/.

./run_sweep_fl_local_updates.sh

Or run directly:

python sweep_fl_local_updates.py --help

Output format

Each sweep produces a JSON file with:

  • top-level metadata (datasets, models, sweep axes, etc.)
  • a runs list, where each entry stores mean/std (over trials) for:
    • instance accuracy and class accuracy
    • evaluated under aux and dummy settings
    • across attacks: ["GDBR", "ZLG", "LLG"]

Repro tips

  • Set --seed (where available) for repeatability.
  • The conda environment pins the main numerical and PyTorch package families to reduce solver drift.
  • Sweep scripts write to logs/ and results/; both directories are ignored by git.

Citation (BibTeX)

@inproceedings{zhang2026gdbr,
  title = {GDBR: Label Recovery Attack Against Partial Gradient Encryption in Federated Learning},
  author = {Rui Zhang and Ka-Ho Chow},
  booktitle = {2026 IEEE 11th European Symposium on Security and Privacy (EuroS&P)},
  year = {2026},
}

About

[EuroS&P 2026] GDBR: Label Recovery Attack Against Partial Gradient Encryption in Federated Learning

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages