CVE-2021-29560: TensorFlow: heap OOB in RaggedTensorToTensor op

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

A heap buffer overflow in TensorFlow's RaggedTensorToTensor operation allows a low-privileged local attacker to read arbitrary memory or crash the TF process. Risk is highest in shared ML platforms, JupyterHub environments, and MLaaS deployments where users can submit arbitrary tensor shapes. Patch to TensorFlow 2.5.0 or the corresponding backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) and audit any service accepting user-controlled RaggedTensor inputs.

What is the risk?

CVSS 7.1 High with local attack vector. The local prerequisite limits internet-scale exposure, but shared ML infrastructure—JupyterHub clusters, multi-tenant GPU farms, Kubeflow pipelines—creates realistic low-privilege attack paths. Dual CWE-125/CWE-787 profile (OOB read + write) enables both memory disclosure and potential code execution. Not in CISA KEV and no known active exploitation, but the low attack complexity means exploitation is straightforward for anyone with local TF access on an unpatched system.

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.1 / 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 None
A High

What should I do?

5 steps
  1. Upgrade TensorFlow to 2.5.0, or apply backports: 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.

  2. Block or sanitize user-controlled tensor shape inputs before they reach tf.raw_ops.RaggedTensorToTensor—validate that parent_output_index length >= row_split length.

  3. In shared platforms (JupyterHub, SageMaker Studio), restrict access to tf.raw_ops namespace for untrusted users.

  4. Enable process-level sandboxing and resource limits for TF inference workers.

  5. Monitor for anomalous process crashes or unexpected OOM events in TF serving pods as an exploitation indicator.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Art.9 - Risk Management System
ISO 42001
A.6.1.4 - AI system lifecycle — third-party components
NIST AI RMF
MANAGE-2.2 - Treatment of identified AI risks
OWASP LLM Top 10
LLM06:2025 - Excessive Agency / Supply Chain

Frequently Asked Questions

What is CVE-2021-29560?

A heap buffer overflow in TensorFlow's RaggedTensorToTensor operation allows a low-privileged local attacker to read arbitrary memory or crash the TF process. Risk is highest in shared ML platforms, JupyterHub environments, and MLaaS deployments where users can submit arbitrary tensor shapes. Patch to TensorFlow 2.5.0 or the corresponding backport (2.4.2, 2.3.3, 2.2.3, 2.1.4) and audit any service accepting user-controlled RaggedTensor inputs.

Is CVE-2021-29560 actively exploited?

Proof-of-concept exploit code is publicly available for CVE-2021-29560, increasing the risk of exploitation.

How to fix CVE-2021-29560?

1. Upgrade TensorFlow to 2.5.0, or apply backports: 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4. 2. Block or sanitize user-controlled tensor shape inputs before they reach tf.raw_ops.RaggedTensorToTensor—validate that parent_output_index length >= row_split length. 3. In shared platforms (JupyterHub, SageMaker Studio), restrict access to tf.raw_ops namespace for untrusted users. 4. Enable process-level sandboxing and resource limits for TF inference workers. 5. Monitor for anomalous process crashes or unexpected OOM events in TF serving pods as an exploitation indicator.

What systems are affected by CVE-2021-29560?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, data preprocessing pipelines, shared ML platforms.

What is the CVSS score for CVE-2021-29560?

CVE-2021-29560 has a CVSS v3.1 base score of 7.1 (HIGH). The EPSS exploitation probability is 0.21%.

What is the AI security impact?

Affected AI Architectures

training pipelinesmodel servingdata preprocessing pipelinesshared ML platforms

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0040 AI Model Inference API Access
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Art.9
ISO 42001: A.6.1.4
NIST AI RMF: MANAGE-2.2
OWASP LLM Top 10: LLM06:2025

What are the technical details?

Original Advisory

TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a heap buffer overflow in `tf.raw_ops.RaggedTensorToTensor`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/d94227d43aa125ad8b54115c03cece54f6a1977b/tensorflow/core/kernels/ragged_tensor_to_tensor_op.cc#L219-L222) uses the same index to access two arrays in parallel. Since the user controls the shape of the input arguments, an attacker could trigger a heap OOB access when `parent_output_index` is shorter than `row_split`. 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 access to a shared ML training cluster (e.g., a compromised data scientist account or malicious insider) crafts a TensorFlow script that calls tf.raw_ops.RaggedTensorToTensor with a row_split tensor longer than parent_output_index. The kernel iterates using the same index across both arrays, reading and writing beyond the allocated heap buffer. In a benign scenario this crashes the worker process. With heap feng shui—allocating controlled objects adjacent to the target buffer—the attacker can overwrite heap metadata or function pointers to achieve code execution within the TF process, potentially pivoting to the underlying host in containerized ML serving environments.

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:N/A:H

Timeline

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

Related Vulnerabilities