Techniqueresearch
Gradient inversion attack
Also called deep leakage from gradients.
Recovers a client's training example in federated learning by optimizing a dummy input until its gradient matches the shared one.
A gradient inversion attack reconstructs a training input from the gradient that a client shares during distributed training, for example in federated learning, where clients send gradients or model updates instead of data. Zhu, Liu and Han (2019) showed that for small batches the gradient is close to a full copy of the input: they recovered images and text by searching for a dummy input whose gradient matches the shared one. The lesson for defenders is that a gradient is personal data, so sharing gradients instead of data gives no privacy by itself. The defenses are secure aggregation, which shows the server only a sum over many clients, and DP-SGD, which clips and noises each example's gradient with a proved bound. This page describes the published results and the defenses at the level of the papers' abstracts; it gives no attack code.
In plain words
In some training systems the data stays on the users' devices. Each device computes how the model should change to fit its own examples, and it sends only that change to a server. This change is called a gradient. People hoped that the gradient hides the data.
It does not hide it well. The gradient of one example is computed from that example by a fixed formula, and for many models the formula can be run backwards, at least roughly. A server that sees the gradient of one small batch can search for an input that would have produced the same gradient, and the result often looks like the real input.
The fixes are to make sure that the server never sees one person's gradient alone, by adding many gradients together in a protocol that hides each part, and to add random noise with a proved privacy bound.
When it applies
The threat model, in the three parts of Biggio and Roli (2018):
- Goal. Privacy: reconstruct a training input (and its label) of one client.
- Knowledge. White box. The server chose the architecture and sent the current parameters to the clients, so it can compute the gradient of any candidate pair .
- Capability. The server observes the update of one client for one round and does not change the protocol: an honest-but-curious server. Later work studies a server that changes the parameters it sends; that is a stronger adversary and this page does not cover it.
The conditions the attack needs, from the published work:
- The server sees the update of one client, not only a sum over many clients.
- The batch behind the update is small. The gradient of a batch of examples is the mean of per-example gradients, so it mixes the inputs; reconstruction quality falls as grows (Zhu et al. 2019; Geiping et al. 2020 report results for batches up to a few dozen images and for updates of several local steps, as measurements on their data).
- The update has no clipping and noise of the kind DP-SGD adds.
- The model is differentiable in the input and the input space is continuous (images, embeddings). For text the attack works on the word embeddings.
The template
The stages of the published method, at the level of the abstract of Zhu et al. (2019), with the point where each defense breaks it:
GRADIENT-INVERSION(view of the server) ▷ the stages only, no parameters- 1
receive the update of one client for one round ▷ defense: secure aggregation shows only a sum - 2
pick a dummy input and a dummy label of the right shape - 3
repeat - 4
compare the gradient of the dummy pair with the received update, by ⟨a distance between gradients⟩ - 5
change the dummy pair to reduce ⟨that distance⟩ plus ⟨a prior on natural inputs⟩ - 6
until ⟨a stopping rule⟩ - 7
return the dummy pair ▷ defense: DP-SGD bounds the chance that it is close to the real input
The holes are the parts that differ between papers. Zhu et al. use the squared Euclidean distance between gradients and no prior. Geiping et al. (2020) use the cosine distance, which ignores the scale of the gradient, and a total variation prior that favors smooth images. Zhao et al. (2020) remove the dummy label from the search: with the cross-entropy loss and a single example, the signs of the gradient of the last layer give the label.
Why a gradient holds the input: an abstract model
Take a made-up first layer with input , weights and bias , followed by any differentiable rest of the model. For one example, write . The chain rule gives
So row of is , and for every with , that row divided by is exactly . This is the observation of Phong et al. (2018). It is a statement about one example and one dense layer with a bias: the gradient of that layer is a scaled copy of its input. For a batch of examples the gradient is , a matrix of rank at most that mixes the inputs, which is why a larger batch and a sum over many clients make reconstruction harder.
Where each defense breaks the template
Secure aggregation breaks L1. In the protocol of Bonawitz et al. (2017), the clients mask their vectors with pairwise random masks that cancel in the sum. Against an honest-but-curious server that colludes with fewer than a threshold number of clients, the server learns nothing about the inputs beyond the sum of the vectors of the clients that finish the round (their security theorem; a variant with authentication covers an active server). So two runs in which the clients hold different updates with the same sum give the server views with the same distribution. The server never gets the update of one client, only a sum over many clients and many batches.
DP-SGD bounds L7. DP-SGD clips each per-example gradient to norm at most and adds Gaussian noise to the sum, which makes the whole training run -differentially private under the replace relation on one example (see approximate differential privacy). This bounds every reconstruction method at once.
Claim. Let be -DP under replace, let the target record be drawn from a prior on a finite set and placed in a fixed dataset , and let be any algorithm that outputs a guess in from the output of . Then .
Proof. By the post-processing theorem, is -DP. Fix any . For each , the datasets and differ in one record, so . Average over : the success probability is at most , since the guesses on one output distribution have total probability 1.
The bound says that DP-SGD cannot make exact reconstruction much more likely than a guess from the prior. It holds for the stated neighbor relation and the exact mechanism; a deployment that clips but adds less noise than the accountant assumes has no such bound.
Classic examples
- Dense layers, Phong et al. (2017, 2018). The gradient of a dense layer with a bias is a scaled copy of its input, as in the abstract model above. Their answer was to encrypt the gradients with additively homomorphic encryption, so that the server adds them without reading them, the same goal as secure aggregation in secure multiparty computation.
- Deep leakage from gradients, Zhu, Liu and Han (2019). Gradient matching with a squared distance recovered images and sentences from the gradient of one small batch of a shared model. They tried noise, lower precision and pruning of small gradient entries as defenses, and in their experiments enough noise or pruning stopped the reconstruction at a cost in accuracy.
- Label recovery, Zhao et al. (2020). For one example and the cross-entropy loss, the label is given by the sign pattern of the last layer gradient, which makes the search over inputs easier.
- Inverting gradients, Geiping et al. (2020). A cosine distance and an image prior reconstruct inputs from deeper networks and from updates of several local steps of stochastic gradient descent, which answers the hope that local training hides the data.
- Related attacks on models, not on gradients. Model inversion works from the outputs of a trained model, membership inference asks only whether a record was used, and training data extraction gets memorized records out of a generative model. The same defenses apply to all four, with DP as the one that bounds them all.
Variations
- The view of the server. One gradient of one batch, one update after several local steps, or a sequence of updates over rounds. Each step away from the first gives a weaker but not zero leak.
- The domain. Images with a smoothness prior, text through embeddings, and tabular data.
- Analytic and optimization based. The dense layer case is solved in closed form; the general case is a non-convex search with no guarantee of success.
- Defenses with and without proofs. Secure aggregation and DP-SGD have security and privacy theorems under stated adversaries. Large batches, gradient compression, pruning and lower precision are heuristics; they raise the cost of the published attacks, and none has a bound against every attack.
Pitfalls
- "We share gradients, not data, so the data is private." This is the claim the attack refutes. Federated training without secure aggregation or DP gives the server a function of each client's data that is often invertible.
- Treating a failed reconstruction as privacy. A reconstruction method that fails on one setting gives a lower bound on leakage, not an upper bound. Only a DP guarantee is an upper bound for every method.
- Secure aggregation with few clients. The sum of two updates, or a round in which the other clients drop out, leaves the server close to one client's update. The protocol bounds what the server learns beyond the sum, so the sum itself must hide each client.
- Noise without an accountant. Adding some noise to updates is not DP unless the per-example sensitivity is bounded by clipping and the noise is calibrated to it by a privacy accountant.
References
- Ligeng Zhu, Zhijian Liu and Song Han, Deep leakage from gradients, Advances in Neural Information Processing Systems 32 (NeurIPS) 2019, arXiv:1906.08935, the gradient matching objective, the results on image and text models, and the defenses they tried (noise, low precision, gradient pruning)
- Jonas Geiping, Hartmut Bauermeister, Hannah Droge and Michael Moeller, Inverting gradients, how easy is it to break privacy in federated learning?, Advances in Neural Information Processing Systems 33 (NeurIPS) 2020, arXiv:2003.14053, the cosine distance between gradients with a total variation prior, the analysis of dense layers, and the attack on updates made of several local steps
- Le Trieu Phong, Yoshinori Aono, Takuya Hayashi, Lihua Wang and Shiho Moriai, Privacy-preserving deep learning via additively homomorphic encryption, IEEE Transactions on Information Forensics and Security 13(5), 2018, the observation that the gradient of a dense layer is proportional to its input, and the use of homomorphic encryption of the gradients as a defense
- Bo Zhao, Konda Reddy Mopuri and Hakan Bilen, iDLG, improved deep leakage from gradients, arXiv:2001.02610, 2020, the recovery of the label from the signs of the gradient of the last layer under the cross-entropy loss
- Keith Bonawitz, Vladimir Ivanov, Ben Kreuter, Antonio Marcedone, H. Brendan McMahan, Sarvar Patel, Daniel Ramage, Aaron Segal and Karn Seth, Practical secure aggregation for privacy-preserving machine learning, ACM CCS 2017, pages 1175 to 1191, the protocol that lets the server learn only the sum of the client vectors, and its security against an honest-but-curious server and against an active one
- Martin Abadi, Andy Chu, Ian Goodfellow, H. Brendan McMahan, Ilya Mironov, Kunal Talwar and Li Zhang, Deep learning with differential privacy, ACM CCS 2016, pages 308 to 318, DP-SGD, per-example clipping of the gradient and Gaussian noise
- Battista Biggio and Fabio Roli, Wild patterns, ten years after the rise of adversarial machine learning, Pattern Recognition 84, 2018, pages 317 to 331, the threat model of goal, knowledge and capability
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag ZGJXQ9 Edit this page History Report an error Markdown