CVE-2021-29514: TensorFlow: heap buffer overflow in RaggedBincount op
HIGH PoC AVAILABLEA heap buffer overflow in TensorFlow's RaggedBincount operation allows a local attacker with low privileges to corrupt memory and potentially execute arbitrary code on ML training or serving infrastructure. Upgrade TensorFlow to 2.5.0, 2.4.2, or 2.3.3 immediately. Multi-tenant ML platforms and shared GPU clusters where users can submit arbitrary TensorFlow jobs are the primary exposure surface.
Risk Assessment
CVSS 7.8 High with local attack vector and low complexity makes this realistic in shared ML infrastructure. While local access is required, this threshold is easily met on JupyterHub servers, Kubeflow clusters, or any multi-tenant ML platform where multiple users submit TensorFlow workloads. Heap buffer overflow with out-of-bounds write (CWE-787) carries high potential for code execution on ML worker nodes, which often have privileged access to training data and model artifacts.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| tensorflow | pip | — | No patch |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
1 step-
1) Patch: upgrade TensorFlow to 2.5.0, 2.4.2, or 2.3.3 — patches are available and backported. 2) If patching is delayed, restrict submission of TensorFlow jobs using RaggedBincount to trusted users only. 3) Isolate ML training workloads via container sandboxing (gVisor, Kata Containers) to contain blast radius. 4) Detection: monitor TensorFlow worker processes for abnormal crashes, segfaults, or memory errors that may indicate exploitation attempts. 5) Audit all shared ML platforms and CI/CD pipelines for unpatched TensorFlow versions using dependency scanners.
Classification
Compliance Impact
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2021-29514?
A heap buffer overflow in TensorFlow's RaggedBincount operation allows a local attacker with low privileges to corrupt memory and potentially execute arbitrary code on ML training or serving infrastructure. Upgrade TensorFlow to 2.5.0, 2.4.2, or 2.3.3 immediately. Multi-tenant ML platforms and shared GPU clusters where users can submit arbitrary TensorFlow jobs are the primary exposure surface.
Is CVE-2021-29514 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2021-29514, increasing the risk of exploitation.
How to fix CVE-2021-29514?
1) Patch: upgrade TensorFlow to 2.5.0, 2.4.2, or 2.3.3 — patches are available and backported. 2) If patching is delayed, restrict submission of TensorFlow jobs using RaggedBincount to trusted users only. 3) Isolate ML training workloads via container sandboxing (gVisor, Kata Containers) to contain blast radius. 4) Detection: monitor TensorFlow worker processes for abnormal crashes, segfaults, or memory errors that may indicate exploitation attempts. 5) Audit all shared ML platforms and CI/CD pipelines for unpatched TensorFlow versions using dependency scanners.
What systems are affected by CVE-2021-29514?
This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, shared ML platforms, ML infrastructure.
What is the CVSS score for CVE-2021-29514?
CVE-2021-29514 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.01%.
Technical Details
NVD Description
TensorFlow is an end-to-end open source platform for machine learning. If the `splits` argument of `RaggedBincount` does not specify a valid `SparseTensor`(https://www.tensorflow.org/api_docs/python/tf/sparse/SparseTensor), then an attacker can trigger a heap buffer overflow. This will cause a read from outside the bounds of the `splits` tensor buffer in the implementation of the `RaggedBincount` op(https://github.com/tensorflow/tensorflow/blob/8b677d79167799f71c42fd3fa074476e0295413a/tensorflow/core/kernels/bincount_op.cc#L430-L446). Before the `for` loop, `batch_idx` is set to 0. The attacker sets `splits(0)` to be 7, hence the `while` loop does not execute and `batch_idx` remains 0. This then results in writing to `out(-1, bin)`, which is before the heap allocated buffer for the output tensor. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2 and TensorFlow 2.3.3, as these are also affected.
Exploitation Scenario
A malicious data scientist on a shared Kubeflow or JupyterHub cluster submits a TensorFlow training job containing a crafted RaggedBincount call where splits[0] is set to 7. This bypasses the while loop guard, keeping batch_idx at 0 and causing a write to out[-1, bin] — before the heap-allocated output buffer. The resulting heap corruption can be leveraged for code execution within the ML worker container. From there, the attacker can exfiltrate co-tenants' model weights, poison shared training datasets, or harvest cloud credentials mounted in the container environment.
Weaknesses (CWE)
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/eebb96c2830d48597d055d247c0e9aebaea94cd5 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-8h46-5m9h-7553 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
AI Threat Alert