Skip to content

Gradient Inversion: How Easy Is It to Break Privacy in Federated Learning?

Inverting Gradients -- How easy is it to break privacy in federated learning?

arXiv· arXiv:2003.14053· Jonas Geiping, Hartmut Bauermeister, Hannah Dröge, Michael MoellerDep. of Electrical Engineering and Computer Science, University of SiegenIndexed by this site · 15 days ago· Originally publishedSelected AttacksSelectedAttention41

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose a gradient inversion attack based on cosine similarity and signed Adam, and claim that images can be reconstructed from gradients shared in federated learning, including for a trained ResNet-152 and a batch of 100 averaged gradients.

Threat modelhonest-but-curious server whose goal is to recover user data: it may store and process each user's uploaded update separately, but must not interfere with the collaborative learning algorithm, modify the model architecture, or send malicious parameters that do not represent the true global model.

Questions
Federated learning shares only gradients rather than raw data and is considered able to protect user privacy. The authors aim to answer how secure shared parameter gradients really are, pointing out that existing attacks succeed only on artificially constructed shallow, smooth, untrained networks, giving a false sense of security.
Methods
Proposes a magnitude-invariant loss based on cosine similarity, combined with a total variation image prior and sign-gradient-based Adam optimization to reconstruct input images; and proves that the input to any fully connected layer can, under certain conditions, be analytically reconstructed from gradients, independent of the rest of the network structure.
Experiments and results
On CIFAR-10 and ImageNet, the authors claim that input images of trained ResNet-18/152 can be reconstructed; under federated averaging with multi-step updates and averaged gradients of up to 100 images, some images remain recognizable (Figure 3, Figure 6, Table 2).
Limitations and future work
The authors point out that the attack effectiveness depends on scenario-specific hyperparameters, and that failure with default parameters does not mean it is safe; the experiments only use image classification networks, and the authors believe image classification may be particularly susceptible to this type of attack; the authors state that provable differential privacy remains the only way to guarantee safety, but it reduces model accuracy.
Experimental setupLeNet (Zhu)、ResNet20-4 et al. · CIFAR-10、CIFAR-100 et al. · PSNR
Evaluated models
LeNet (Zhu)ResNet20-4ConvNetResNet-18ResNet-34ResNet-50ResNet-152ResNet32-10
Benchmarks
CIFAR-10CIFAR-100ILSVRC2012 (ImageNet) validation set
Metrics
PSNR
AI summaryand selection rationaleResearchers at the University of Siegen in Germany propose a gradient inversion attack against federated learning, showing that sharing only parameter gradients is not sufficient to protect user data privacy. The attack constructs a magnitude-invariant loss using cosine similarity, together with sign Adam optimization inspired by adversarial attack ideas and total variation regularization, to reconstruct input images from the gradients uploaded by users. Experiments show that attacks previously feasible only on shallow, smooth, untrained networks can, with this method, also recover recognizable ImageNet images on a trained ResNet-152; the paper also proves that the input to any fully connected layer can be analytically reconstructed, and that partial images can still be recovered from gradients averaged over up to 100 images and from multi-step local updates in federated averaging. The authors analyze under an honest-but-curious server threat model and argue that provable differential privacy remains the only way to guarantee security. Code is open-sourced at https://github.com/JonasGeiping/invertinggradients。

Researchers at the University of Siegen in Germany propose a gradient inversion attack against federated learning, showing that sharing only parameter gradients is not sufficient to protect user data privacy. The attack constructs a magnitude-invariant loss using cosine similarity, together with sign Adam optimization inspired by adversarial attack ideas and total variation regularization, to reconstruct input images from the gradients uploaded by users. Experiments show that attacks previously feasible only on shallow, smooth, untrained networks can, with this method, also recover recognizable ImageNet images on a trained ResNet-152; the paper also proves that the input to any fully connected layer can be analytically reconstructed, and that partial images can still be recovered from gradients averaged over up to 100 images and from multi-step local updates in federated averaging. The authors analyze under an honest-but-curious server threat model and argue that provable differential privacy remains the only way to guarantee security. Code is open-sourced at https://github.com/JonasGeiping/invertinggradients。

Why it was selectedThe paper shows that sharing only gradients is not sufficient to protect privacy: trained deep networks and gradients averaged over 100 images still leak image content, which teams doing federated learning can use to assess risk.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Whether sharing gradients in federated learning is safe: the authors state that images can be reconstructed from gradients with high fidelity, including on trained deep networks and from multi-image averaged gradients.

    Core question: Does federated learning, which shares only parameter gradients (rather than raw data), really protect user privacy—can an attacker reconstruct input images from gradients.

    • Problem setting: In federated learning, users send gradients computed from local data to a server for aggregation. The paper cites [3] as saying that the industry believes updates are transient and focused, and that raw data cannot be recovered; this paradigm has been used in privacy-sensitive scenarios such as hospital data [15] and text prediction on mobile devices [3].
    • Shortcomings of existing methods: The authors state that prior gradient inversion attacks [34, 38, 37] succeeded only in artificially constructed settings—shallow (4-layer CNN), smooth activation (sigmoid), no stride, with a large fully connected layer, uniform random initialization—where even a single image is difficult to reconstruct, and ImageNet-sized images cannot be recovered, thus giving a false sense of security.
    • Core observation: The authors argue that the magnitude of gradients reflects only the training state, whereas high-dimensional directions carry important information about the input, so an angle-based (cosine similarity) objective should be optimized rather than Euclidean distance; and they observe that this optimization problem is related to finding adversarial perturbations, so optimization strategies from adversarial attacks can be borrowed.
    • Paper contributions: Propose a general optimization-based reconstruction attack; prove that the input to any fully connected layer can be analytically reconstructed from gradients under technical conditions (Proposition 3.1); analyze the impact of architecture and training parameters on reconstruction difficulty; and discuss practical settings such as federated averaging and averaging gradients over multiple images.
    • Threat model:
      • Attacker goal: An honest-but-curious server intending to recover user data.
      • Capabilities: Can store and process a single user's uploaded update individually.
      • Constraints: Must not interfere with the collaborative learning algorithm, must not modify the model architecture to facilitate the attack, and must not send malicious parameters that do not represent the true global model.
      • Victim system: Users participating in federated SGD or federated averaging; Section 6 allows users to accumulate data locally (multiple images, multiple steps).
  2. What related research exists?

    Related work includes gradient inversion attacks, attribute inference, model inversion, and visual representation inversion; the authors state that the assumptions of the former are too strong and the setting unrealistic.

    Recovering data from gradients

    • [28, 27] (Phong et al.) — the earliest discussion of recovering image data from gradients, proving recovery is possible for a single neuron or linear layer.
    • [34] (Wang et al.) — proved that a single image can be recovered for a 4-layer CNN with a large fully connected layer, first constructing a "representation" of the input and then enhancing it with a GAN.
    • [38] (Zhu et al., Deep Leakage from Gradients) — extended to jointly reconstructing labels and showed recovery of multiple images from averaged gradients (maximum batch of 8); the paper notes that its network is a 4-layer CNN with sigmoid activations, no stride, and uniform random weights, and gives no practical results for deeper architectures.
    • [37] (iDLG) — pointed out that label information can be computed analytically from the last-layer gradients; this paper accordingly treats labels as known.
    • The authors point out that the assumptions these works make about architecture and parameters make reconstruction easier, violating the threat model considered in this paper, and that the scenarios are not realistic enough; their common mechanism is optimizing a Euclidean matching term (Eq. 3) with L-BFGS, and L-BFGS requires third-order derivative approximations, which poses a challenge for ReLU networks whose higher-order derivatives are discontinuous.

    Property inference

    • [26, 11] — recovering input properties from local updates (e.g., whether a person is wearing a hat in face recognition), an easier problem than full image reconstruction; task-irrelevant properties can also be recovered from deep layers of the network.

    Model inversion and visual representation inversion

    • [10, 36] — model inversion: recovering training images from network parameters after training; the authors state this is difficult for deep networks without additional information and can be viewed as the natural limiting case of the setting in this paper.
    • [9, 8, 23] — reconstructing input images from intermediate-layer outputs, which leaks information such as composition and dominant colors; this paper proves that recovering from gradients is strictly easier than inverting from visual representations.

    Baselines and benchmarks: the comparison baseline is the Euclidean loss (Eq. 3) + L-BFGS optimization of [34, 38, 37] (allowing 16 restarts); the datasets are CIFAR-10, CIFAR-100, and the ILSVRC2012 (ImageNet) validation set.

    The authors position this paper as a gradient inversion attack that still works on realistic architectures (deep, non-smooth, trained networks) and under practical federated averaging settings, rather than a proof of concept on idealized architectures.

  3. How does the paper address this problem?

    Replace the Euclidean loss with cosine similarity and L-BFGS with signed Adam, optimize the reconstruction with a total variation prior; and provide an analytical reconstruction proof for fully connected layers.

    Overall idea: change "find an image whose gradient matches the observed gradient" to "find an image whose gradient direction agrees with the observed gradient", optimize using an angle-based magnitude-invariant loss plus an image prior, and draw on the sign-gradient optimization strategy from adversarial attacks. The method has no separate name; the paper calls it the "proposed approach".

    Theoretical analysis: analytical reconstruction of fully connected layers

    • Proposition 3.1: if the network contains a fully connected layer with a bias, is preceded only by (possibly bias-free) fully connected layers, and the derivative of the loss with respect to the outputs of these layers has at least one nonzero element, then the network input can be uniquely analytically reconstructed from the gradient without solving an optimization problem, regardless of the layer's position in the network.
    • Proof idea (full version in Appendix D): by the chain rule, the input to a layer can be computed iteratively layer by layer from the ratio of the derivative of the loss with respect to that layer's outputs to the derivative with respect to that layer's weight row vectors.
    • Corollary: many classification networks end with a fully connected layer, whose input (i.e., the activations of the preceding layers) can be analytically reconstructed; therefore, for classification networks ending in a fully connected layer, recovering the input from gradients is strictly easier than inverting the visual representation from the last convolutional layer.

    Numerical reconstruction method

    • Magnitude-invariant loss: the authors believe that gradient magnitude reflects only the training state (the data point's local optimality relative to the current model), and that only direction carries input information, so they use cosine similarity as the cost: argminx∈[0,1]n 1 − (⟨ ∇θ Lθ(x,y), ∇θ Lθ(x∗,y)⟩)/(|∇θ Lθ(x,y)||∇θ Lθ(x∗,y)|) + α  TV(x), i.e., minimizing 1 minus the cosine similarity plus a total variation prior (Eq. 4); the paper states this is equivalent to minimizing the Euclidean loss under the constraint that both gradients are normalized to magnitude 1.
    • Optimization strategy: the authors point out that this problem is related to finding adversarial perturbations, so they use only the sign of the gradient of the objective with respect to x and optimize with Adam with momentum and step-size decay; the sign affects only Adam's first and second moments, and the actual update step remains unsigned.
    • Label handling: labels are not jointly optimized; following the conclusion of [37], labels are treated as analytically obtainable, i.e., known.

    Extension to federated averaging

    • Given the old parameters, the parameters after local updates, the learning rate, and the number of update steps, the parameter difference can be written as the sum of the gradients at each step (Eq. 5); for multi-step settings, the gradient in Eq. 4 is replaced by the sum of the gradients at each step before taking the cosine similarity (Eq. 6), and automatic differentiation is used to backpropagate to x.
    • The paper assumes the server knows the number of local update steps, and states that the number of steps is a small integer and can also be obtained by brute-force search.

    Hyperparameters and implementation (Appendices B, C)

    • Reconstruction is initialized from a Gaussian distribution with mean 0 and variance 1; the default step size is 0.1 (range [0.01, 1]), and 1 is used in the federated averaging experiments; at most 24000 iterations, with decay by a factor of 0.1 at 3/8, 5/8, and 7/8.
    • The default TV weight is 0.01, adjusted by scenario (Table 4 and Table 5 list the values used in each experiment); except for multiple restarts given to the L-BFGS baseline, the method in this paper uses only a single restart, and the authors state that multiple restarts can moderately improve the success rate but are computationally expensive.
    • The authors emphasize that the optimal hyperparameters depend on the specific attack scenario, and that failure of the attack under default parameters does not constitute a security guarantee.
  4. What experiments did the paper conduct?

    Compare with baselines on CIFAR-10/ImageNet and conduct experiments on architecture, training state, federated averaging, and multi-image batches; the authors claim reconstruction is still possible for a trained ResNet-152 and with 100-image averaged gradients.

    Experimental setup

    • Architectures tested: LeNet (Zhu) (reproducing the shallow, smooth CNN of [38]), ResNet20-4, ResNet-18/34/50, ResNet-152, and a self-built ConvNet (8 convolutional layers + BN + ReLU, default width D=64, CIFAR-10 accuracy above 90%); both trained and untrained parameter states are used.
    • Datasets: CIFAR-10 validation set (the first 100 images for quantitative experiments, the first 10 images for some), CIFAR-100 (100-image batch experiments), ILSVRC2012 validation set (images taken every 1000 by ID, not manually selected).
    • Baseline: Euclidean loss (Eq. 3) + L-BFGS, learning rate 1e-4, 300 iterations, 8 restarts on ResNet and 16 restarts on LeNet (Zhu); the method in this paper uses only a single restart, 4800 iterations, and learning rate 0.1 in these comparison experiments.
    • Metric: PSNR between reconstructed and original images (mean ± standard deviation), supplemented by qualitative displays.
    • Federated averaging settings (Table 2): untrained ConvNet, learning rate 1, 4800 iterations, single restart, 5 (E, n, B) combinations, 100 experiments each; images with the same label are not used within the same mini-batch to avoid order ambiguity.
    • The paper does not report a reviewer model or human evaluation; reconstruction quality relies on figures in addition to PSNR.

    Main results

    Table 1: average PSNR (± standard deviation) of single-image reconstruction on the first 100 validation images of CIFAR-10:

    Swipe horizontally to read the table

    ArchitectureParametersEuclidean loss + L-BFGSMethod in this paper
    LeNet (Zhu)Untrained46.25 ± 12.6618.00 ± 3.33
    LeNet (Zhu)Trained13.24 ± 5.4418.08 ± 4.27
    ResNet20-4Untrained10.29 ± 5.3819.83 ± 2.96
    ResNet20-4Trained6.90 ± 2.8013.95 ± 3.38
    • The authors state that the baseline performs well on untrained, smooth, shallow architectures but fails completely on trained ResNet; the method in this paper yields recognizable images in every setting, and is especially good in the realistic setting of trained ResNet (Figure 2).
    • The authors point out that on trained ResNet the visual quality of reconstruction is better than on untrained ResNet, despite the lower PSNR (Table 1 and Figure 2).
    • ImageNet single-image reconstruction (Figure 3, trained ResNet-152): the authors state that the amount of information leaked per image depends heavily on image content — some images (e.g., two tench fish) are almost completely leaked, while a black swan leaks almost no usable information.

    Effects of training state, translation invariance, and architecture

    • Trained networks: the authors observe two effects (Figure 3): reconstructions are implicitly biased toward typical features of the same class in the training data (e.g., bluer feathers, larger eyes), hindering detail and background recovery; data augmentation during training makes object localization harder, so object positions are not preserved and duplicates appear (e.g., snakes and geckos).
    • Translation-invariant convolution: a provably translation-invariant CNN with circular padding makes object localization impossible (the original object is split apart), whereas a conventional zero-padding CNN can recover relatively high-quality images; the authors accordingly regard zero padding as a source of privacy risk (inline figure in the main text, no quantitative table).
    • Width and depth (Figure 4, average PSNR over the first 10 CIFAR-10 images): for ResNet-18 with width 16/64/128, the average PSNR is 19.02/22.04/22.94, with variance increasing with width; ResNet-18/34/50 give 21.59/20.98 (22.04 at width 64); the authors state that the attack degrades little with increasing depth, and that greater width only increases the attacker's computation and does not provide higher security.

    Federated averaging and multi-image recovery

    • Multi-step updates (Figure 5, n=B=1): at learning rate 1e-4, reconstruction after 1 step and 100 steps is 19.77dB and 19.39dB respectively, with quality unaffected; at 5 steps, learning rate 1e-2 gives 23.74dB, while 1e-1 gives only 4.96dB — the authors state this is the only failure case, but that this learning rate causes training to diverge and produce no useful updates.
    • 100-image averaged gradient (Figure 6, CIFAR-100, ResNet32-10): most reconstructed images are unrecognizable, but the 5 most recognizable images are shown; the authors state that the distortion caused by batching is uneven, objects in some images remain easily recognizable, and averaging over 100 images also cannot fully protect privacy.
    • General case (Table 2, first 100 CIFAR-10 images, untrained ConvNet, average PSNR ± standard deviation):
    Setting (E, n, B)PSNR
    1 epoch, 4 images, B=216.92 ± 2.10
    1 epoch, 8 images, B=214.66 ± 1.12
    1 epoch, 8 images, B=816.49 ± 1.02
    5 epoch, 1 image, B=125.05 ± 3.28
    5 epoch, 8 images, B=816.58 ± 0.96
    • The authors state that single-image reconstruction has the highest PSNR and is the most vulnerable; privacy leakage is still observed in all multi-image settings; the conclusion that multiple epochs do not make reconstruction harder also applies to multiple images.

    Other ablations and analyses

    • Table 3 (trained ResNet-18, first 10 CIFAR-10 images): base setting 20.12 dB (±1.02); with L2 loss 15.13 dB (±0.70); without total variation 19.96 dB (±0.75); with L-BFGS 5.13 dB (±0.50). The authors state that the Adam optimizer and the similarity loss are core, the TV benefit is small, and the sign-gradient benefit is even smaller.
    • Appendix A threat model variants: the authors state that if malicious architectures are allowed (e.g., a fully connected layer in the first layer, invertible blocks) or malicious parameters (e.g., setting convolution to the identity mapping, swapping two rows of the classification layer to flip labels), reconstruction becomes nearly trivial; Figure 7 shows that label flipping can improve PSNR.
    • Appendix E: Figure 9 gives reconstructions and PSNR for the worst/best samples by gradient magnitude on trained/untrained ConvNet and ResNet20-4; Figure 12 gives failure cases on ImageNet (text on an ambulance, the number of flower petals not recovered).
  5. What are some points that can be further explored?

    The authors point out that hyperparameters depend on the scenario, that image classification may be especially vulnerable, and state that provable differential privacy remains the only security guarantee; the experiments are limited to image classification architectures.

    Limitations and future directions noted by the authors

    • Hyperparameter dependence on scenario (Appendix C): the optimal hyperparameters of the attack depend on the specific attack scenario; failure of the attack under default parameters does not guarantee security.
    • Vulnerability of image classification (Broader Impact): the authors believe image classification may be especially susceptible to this type of attack, for reasons including the intrinsic structure of image data, the scale of image classification networks, and the relatively small number of images owned by a single user.
    • The attack is only a first step (Broader Impact): the authors state that this attack is likely only a first step toward stronger attacks, and that how to protect data privacy while collaboratively training high-accuracy models remains largely unsolved.
    • The cost of defense (Conclusions and Broader Impact): the authors state that provable differential privacy remains the only way to guarantee security (even for larger batches), but differential privacy noticeably degrades model accuracy [14], and differential privacy and secure aggregation are costly to implement.
    • Future research directions (Broader Impact): the authors state that further research is needed on privacy-preserving learning techniques that render the attack in this paper ineffective, which may be defense mechanisms or computable guarantees that let practitioners verify whether their applications are vulnerable to the attack.

    Scope of experimental coverage

    • The architectures tested are LeNet (Zhu), ResNet20-4, ResNet-18/34/50, ResNet-152, and ConvNet, all image classification networks; the datasets are CIFAR-10, CIFAR-100, and the ILSVRC2012 validation set.
    • The quantitative experiments use the first 100 images of the CIFAR-10 validation set (Table 1, Table 2) or the first 10 images (Figure 4, Table 3); federated averaging uses 100 experiments per setting.
    • The federated averaging experiments (Table 2, Figure 5) use an untrained ConvNet; multi-image mini-batches use only images with different labels, and same-label combinations are not considered.
    • The method in this paper uses a single restart in all quantitative experiments; the paper states that multiple restarts can further improve the attack but were not included in the quantitative evaluation.
    • The paper does not report the attack's runtime or number of queries (it only states that the method in this paper takes less time than L-BFGS optimization), nor quantitative metrics other than PSNR, nor human evaluation.
  6. Summarize the main content of the paper

    The authors propose a gradient inversion attack based on cosine similarity and signed Adam, and state that images can still be reconstructed on trained deep networks and from gradients averaged over 100 images.

    An attack paper on federated learning privacy: it answers "how safe are shared parameter gradients" and gives theoretical and empirical results.

    • Problem: federated learning uploading only gradients is considered to protect privacy, but the authors state that prior attacks succeeded only on shallow, smooth, untrained artificial networks, creating a false sense of security.
    • Method: replace Euclidean matching with a magnitude-invariant cosine similarity loss, add a total variation prior, and reconstruct the input using Adam optimization based on sign gradients; theoretically prove that the input to any fully connected layer can, under technical conditions, be analytically reconstructed from gradients (Proposition 3.1), independent of the rest of the network structure.
    • Single-image results: on CIFAR-10, trained ResNet20-4 achieves an average PSNR of 13.95 ± 3.38, while the baseline (Euclidean loss + L-BFGS) achieves only 6.90 ± 2.80 (Table 1); the authors state that ImageNet images can also be faithfully reconstructed on trained ResNet-152, with the degree of leakage varying by image (Figure 3).
    • Architecture analysis: the authors state that depth hardly reduces reconstructability, and greater width only increases the attack's computation; conventional zero padding is regarded by the authors as a source of privacy risk, and translation-invariant convolution makes localization fail.
    • Practical settings: reconstruction quality is unaffected after 100 local update steps of federated averaging (19.77dB → 19.39dB, Figure 5); under the averaged gradient of 100 CIFAR-100 images, 5 images remain recognizable (Figure 6); ablations show that Adam and the similarity loss are core, and switching to L-BFGS drops PSNR from 20.12 dB to 5.13 dB (Table 3).
    • Authors' conclusion: even multi-image federated averaging cannot guarantee the privacy of all users' data; the authors believe provable differential privacy remains the only security guarantee but degrades model accuracy, and call for research on privacy-preserving techniques that render such attacks ineffective.

Related papers

Show 3 more papers
Read originalarxiv.org