GuardAgainstGradient is the overarching research repository and empirical benchmark suite investigating Gradient Inversion Attacks (GIAs) and defense mechanisms in Federated Learning.
FL-PrivAudit is the software framework and decision-support toolkit resulting from this research. It translates empirical vulnerability benchmarks into an automated, zero-compute privacy risk scoring engine (available via CLI and interactive web dashboard).
In Federated Learning (FL), clients collaboratively train models by sharing gradient updates rather than raw data. However, honest-but-curious servers can mathematically invert these gradients to reconstruct private training samples.
This repository provides two components:
- The Research Benchmark (
experiments/): Systematic empirical studies uncovering the capacity confounder in model architectures (ResNet-18 vs. PlainCNN-Wide) and evaluating the empirical privacy-utility trade-offs of passive vs. active defenses. - The Auditing Toolkit (
FL-PrivAudit): An instant risk-profiling tool (fl_privaudit.py&app.py) that scores any FL configuration from 0 to 100 without requiring expensive GPU attack simulations.
- Architecture-Aware Scoring: Corrects for the capacity confounder — evaluates the privacy impact of residual skip connections with parameter counts controlled.
-
Free vs. Costly Defense Hierarchy: Empirically benchmarks zero-cost structural choices (GroupNorm + Batch Size
$\ge 8$ ) against active Differential Privacy noise, demonstrating comparable empirical protection with zero model utility degradation. - Instant Zero-GPU Auditing: Computes calibrated privacy risk scores (0–100) and PSNR estimates in milliseconds using empirical weights validated across 48 attack runs (Mean Absolute Error: 0.53 dB).
- Interactive Web Dashboard: A Streamlit-based interface providing live parameter control, component-level factor breakdowns, and actionable model hardening recommendations.
GuardAgainstGradient/
├── app.py # Interactive Streamlit Web Dashboard
├── fl_privaudit.py # Command-Line Privacy Auditing Tool
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
├── README.md # Project documentation
├── src/ # Framework source code
│ ├── models/ # Model definitions (ResNet-18, PlainCNN, LeNet)
│ ├── attacks/ # Cosine gradient inversion attack & metrics
│ ├── defenses/ # Gradient pruning & DP perturbation routines
│ ├── audit/ # PrivacyRiskScorer engine & report generators
│ └── utils/ # Dataset loaders & seed utilities
├── experiments/ # Reproducible benchmark experiment scripts
│ ├── 01_sanity_check.py # Phase 1: MNIST baseline validation
│ ├── 02_cifar_baseline.py # Phase 2: CIFAR-10 baseline & capacity observation
│ ├── 03_ablation_grid.py # Phase 3: Capacity-equalized ablation sweep
│ ├── 04_defenses.py # Phase 4: Pruning and DP noise evaluation
│ ├── 05_build_risk_model.py # Phase 5: Scorer calibration & validation
│ └── 06_paper_figures.py # Phase 6: Publication figure generation
└── results/ # Benchmark metrics, figures, and plots
git clone https://github.com/<your-username>/GuardAgainstGradient.git
cd GuardAgainstGradient
pip install -r requirements.txtstreamlit run app.pyRun static audits or comparative benchmarks directly from the terminal:
# Instant audit of baseline ResNet-18
python fl_privaudit.py --arch resnet18 --norm batchnorm --batch-size 1
# Audit a hardened model configuration
python fl_privaudit.py --arch plain_cnn --norm groupnorm --batch-size 8 --dp-noise 0.10
# Side-by-side comparison across baseline, free defenses, and DP
python fl_privaudit.py --compare
# (Optional) Live GPU attack verification
python fl_privaudit.py --arch resnet18 --norm batchnorm --batch-size 1 --live --device cudaThe framework is grounded in systematic empirical benchmarks:
-
Phase 1 (
experiments/01_sanity_check.py): Verified cosine gradient matching on MNIST (LeNet-5, 16.82 dB). -
Phase 2 (
experiments/02_cifar_baseline.py): Identified the capacity confounder on CIFAR-10. -
Phase 3 (
experiments/03_ablation_grid.py): Parameter-equalized ablation (~11.2M params) isolating skip connections (+0.24 dB), GroupNorm (-0.34 dB), and Batch Size 8 (-0.41 dB). -
Phase 4 (
experiments/04_defenses.py): Evaluated gradient pruning (90%, 95%, 99%) and DP-SGD noise ($\sigma \in {0.01, 0.10}$ ). -
Phase 5 (
experiments/05_build_risk_model.py): Validated the scoring engine against ground-truth benchmarks (MAE = 0.53 dB). -
Phase 6 (
experiments/06_paper_figures.py): Generated publication-quality figures (results/phase6_figures/).
| Configuration | Risk Score | Level | Est. PSNR | Utility Cost |
|---|---|---|---|---|
| Worst-Case Baseline (ResNet, BN, B=1) | 61/100 | HIGH | 13.39 dB | None |
| Free Defenses Only (PlainCNN, GN, B=8) | 53/100 | HIGH | 12.40 dB | Zero Accuracy Loss |
| Moderate DP Only ( |
58/100 | HIGH | 12.94 dB | Minor Convergence Penalty |
| Free Defenses + Moderate DP | 50/100 | MODERATE | 11.95 dB | Minor Convergence Penalty |
| Maximum Hardening (GN, B=32, Prune 99%, DP 0.1) | 39/100 | MODERATE | 10.65 dB | High Accuracy Loss |
This project is licensed under the MIT License - see the LICENSE file for details.