CVE-2021-29579: TensorFlow: heap buffer overflow in MaxPoolGrad kernel
HIGH PoC AVAILABLETensorFlow's MaxPoolGrad operation contains a heap buffer overflow (OOB write) exploitable by any local user with low privileges — a serious risk in shared ML training clusters and multi-tenant Jupyter environments. Patch immediately to TF 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4). Treat unpatched TensorFlow training nodes as high-risk lateral movement surfaces, particularly in Kubernetes-based ML pipelines where service accounts carry elevated permissions.
What is the risk?
CVSS 7.8 HIGH with local attack vector, low complexity, and low privileges required. While remote exploitation requires indirect access (malicious notebook submission, shared cluster), the combination of low complexity and full C/I/A impact makes this dangerous in multi-tenant ML environments. Not in CISA KEV; no evidence of active in-the-wild exploitation. Risk is materially elevated for organizations running shared GPU/TPU training infrastructure where multiple users submit jobs to the same nodes.
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| TensorFlow | pip | — | No patch |
Do you use TensorFlow? You're affected.
How severe is it?
What is the attack surface?
What should I do?
6 steps-
Upgrade TensorFlow to 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your current branch — confirm with
python -c 'import tensorflow as tf; print(tf.__version__)'on all hosts. -
Inventory all TensorFlow deployments: include training clusters, CI/CD pipelines, notebook servers, and model serving containers.
-
Apply network segmentation to isolate ML training nodes from production systems.
-
Restrict local shell access to training nodes — audit which accounts have SSH/console access and apply least privilege.
-
Enable process and file integrity monitoring on TF training hosts.
-
For Kubernetes ML pipelines: audit service account permissions on nodes running TensorFlow training jobs.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29579?
TensorFlow's MaxPoolGrad operation contains a heap buffer overflow (OOB write) exploitable by any local user with low privileges — a serious risk in shared ML training clusters and multi-tenant Jupyter environments. Patch immediately to TF 2.5.0 or the respective backport (2.4.2, 2.3.3, 2.2.3, 2.1.4). Treat unpatched TensorFlow training nodes as high-risk lateral movement surfaces, particularly in Kubernetes-based ML pipelines where service accounts carry elevated permissions.
Is CVE-2021-29579 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29579, increasing the risk of exploitation.
How to fix CVE-2021-29579?
1. Upgrade TensorFlow to 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4 depending on your current branch — confirm with `python -c 'import tensorflow as tf; print(tf.__version__)'` on all hosts. 2. Inventory all TensorFlow deployments: include training clusters, CI/CD pipelines, notebook servers, and model serving containers. 3. Apply network segmentation to isolate ML training nodes from production systems. 4. Restrict local shell access to training nodes — audit which accounts have SSH/console access and apply least privilege. 5. Enable process and file integrity monitoring on TF training hosts. 6. For Kubernetes ML pipelines: audit service account permissions on nodes running TensorFlow training jobs.
What systems are affected by CVE-2021-29579?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, shared notebook environments, ML training clusters.
What is the CVSS score for CVE-2021-29579?
CVE-2021-29579 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.21%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0049 Exploit Public-Facing Application Compliance Controls Affected
What are the technical details?
Original Advisory
TensorFlow is an end-to-end open source platform for machine learning. The implementation of `tf.raw_ops.MaxPoolGrad` is vulnerable to a heap buffer overflow. The implementation(https://github.com/tensorflow/tensorflow/blob/ab1e644b48c82cb71493f4362b4dd38f4577a1cf/tensorflow/core/kernels/maxpooling_op.cc#L194-L203) fails to validate that indices used to access elements of input/output arrays are valid. Whereas accesses to `input_backprop_flat` are guarded by `FastBoundsCheck`, the indexing in `out_backprop_flat` can result in OOB access. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3 and TensorFlow 2.1.4, as these are also affected and still in supported range.
Exploitation Scenario
An attacker with low-privilege shell access to a shared GPU training server — for example, a data scientist account on a multi-tenant ML cluster — crafts a malicious TensorFlow script invoking `tf.raw_ops.MaxPoolGrad` with specially crafted tensor shapes that trigger the OOB write in `out_backprop_flat`. The heap corruption enables arbitrary code execution in the TensorFlow process context. If the training job runs under a Kubernetes service account with broad permissions (common in MLOps pipelines), the attacker escalates to cluster-wide access — enabling trained model exfiltration, training data theft, or lateral movement to adjacent production systems sharing the cluster.
Weaknesses (CWE)
CWE-787 Out-of-bounds Write
Primary
CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer CWE-787 — Out-of-bounds Write: The product writes data past the end, or before the beginning, of the intended buffer.
- [Requirements] Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the programmer. Be wary that a language's interface to native code may still be subject to overflows, even if the language itself is theoretically safe.
- [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. Examples include the Safe C String Library (SafeStr) by Messier and Viega [REF-57], and the Strsafe.h library from Microsoft [REF-56]. These libraries provide safer versions of overflow-prone string-handling functions.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H References
- github.com/tensorflow/tensorflow/commit/a74768f8e4efbda4def9f16ee7e13cf3922ac5f7 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-79fv-9865-4qcv Exploit Patch 3rd Party
Timeline
Related Vulnerabilities
CVE-2020-15196 9.9 TensorFlow: heap OOB read in sparse/ragged count ops
Same package: tensorflow CVE-2020-15205 9.8 TensorFlow: heap overflow in StringNGrams, ASLR bypass
Same package: tensorflow CVE-2020-15208 9.8 TFLite: OOB read/write via tensor dimension mismatch
Same package: tensorflow CVE-2019-16778 9.8 TensorFlow: heap overflow in UnsortedSegmentSum op
Same package: tensorflow CVE-2022-23587 9.8 TensorFlow: integer overflow in Grappler enables RCE
Same package: tensorflow