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.

What is the risk?

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.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
TensorFlow pip No patch
195.8K OpenSSF 7.1 3.7K dependents Pushed 2d ago 4% patched ~1372d to patch Full package profile →

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
7.8 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 11% 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, VulnCheck KEV, CISA SSVC, EPSS, Metasploit, Exploit-DB, trickest/cve, Nuclei templates, and inthewild.io exploitation reports.

What is the 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

What should I do?

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.

How is it classified?

Which compliance frameworks are affected?

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.21%.

What is the AI security impact?

Affected AI Architectures

training pipelinesmodel servingshared ML platformsML infrastructure

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0043.003 Manual Modification
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Art. 15
ISO 42001: A.6.2
NIST AI RMF: MANAGE 2.4
OWASP LLM Top 10: LLM03

What are the technical details?

Original Advisory

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)

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

Timeline

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

Related Vulnerabilities