CVE-2021-29514: TensorFlow: heap buffer overflow in RaggedBincount op

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

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.

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
195.0K OpenSSF 7.2 3.7K dependents Pushed 6d ago 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
7.8 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 2% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Moderate
Exploitation Confidence
medium
Public PoC indexed (trickest/cve)
Composite signal derived from CISA KEV, CISA SSVC, EPSS, trickest/cve, and Nuclei templates.

Attack Surface

AV AC PR UI S C I A
AV Local
AC Low
PR Low
UI None
S Unchanged
C High
I High
A High

Recommended Action

1 step
  1. 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:

EU AI Act
Art. 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.2 - AI system risk assessment
NIST AI RMF
MANAGE 2.4 - Residual risks from third-party components are managed
OWASP LLM Top 10
LLM03 - Supply Chain Vulnerabilities

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

Timeline

Published
May 14, 2021
Last Modified
November 21, 2024
First Seen
May 14, 2021

Related Vulnerabilities