CVE-2021-29560: TensorFlow: heap OOB in RaggedTensorToTensor op
HIGH PoC AVAILABLEA 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.
Risk Assessment
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.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| tensorflow | pip | — | No patch |
Do you use tensorflow? You're affected.
Severity & Risk
Attack Surface
Recommended Action
5 steps-
Upgrade TensorFlow to 2.5.0, or apply backports: 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.
-
Block or sanitize user-controlled tensor shape inputs before they reach tf.raw_ops.RaggedTensorToTensor—validate that parent_output_index length >= row_split length.
-
In shared platforms (JupyterHub, SageMaker Studio), restrict access to tf.raw_ops namespace for untrusted users.
-
Enable process-level sandboxing and resource limits for TF inference workers.
-
Monitor for anomalous process crashes or unexpected OOM events in TF serving pods as an exploitation indicator.
Classification
Compliance Impact
This CVE is relevant to:
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.01%.
Technical Details
NVD Description
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)
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H References
- github.com/tensorflow/tensorflow/commit/a84358aa12f0b1518e606095ab9cfddbf597c121 Patch 3rd Party
- github.com/tensorflow/tensorflow/security/advisories/GHSA-8gv3-57p6-g35r 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