CVE-2021-29609: TensorFlow: SparseAdd heap OOB write and null deref

HIGH PoC AVAILABLE
Published May 14, 2021
CISO Take

If your ML environment runs TensorFlow < 2.5.0 and accepts user-influenced sparse tensor inputs, patch immediately to 2.5.0 or the backported fixes (2.4.2, 2.3.3, 2.2.3, 2.1.4). Low attack complexity means any caller with tensor access to the runtime can trigger this. Shared GPU clusters and multi-tenant inference services are highest risk.

Risk Assessment

CVSS 7.8 High with local attack vector and low complexity/privileges. In ML contexts 'local' frequently maps to inference server processes or training jobs where user-submitted data reaches TF ops directly — effectively elevating the practical attack surface beyond what the CVSS vector implies. Risk is highest in multi-tenant GPU clusters or inference APIs that accept raw tensor inputs without pre-validation at the application boundary.

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 5% 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

5 steps
  1. Patch: Upgrade to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4.

  2. Validate all incoming tensor shapes and indices at the application boundary before passing to SparseAdd — reject tensors where indices second dimension does not match the corresponding shape tensor.

  3. Isolate TF inference workers in containers with no-new-privileges and seccomp profiles to contain blast radius.

  4. Audit inference APIs and gRPC endpoints that accept sparse tensor formats from external callers.

  5. Monitor for unexpected TF serving process crashes as a detection signal for exploitation attempts.

Classification

Compliance Impact

This CVE is relevant to:

EU AI Act
Article 9 - Risk management system
ISO 42001
A.6.2.6 - AI system security and resilience
NIST AI RMF
MANAGE 2.4 - Residual risks from third-party AI components are managed
OWASP LLM Top 10
LLM04 - Model Denial of Service

Frequently Asked Questions

What is CVE-2021-29609?

If your ML environment runs TensorFlow < 2.5.0 and accepts user-influenced sparse tensor inputs, patch immediately to 2.5.0 or the backported fixes (2.4.2, 2.3.3, 2.2.3, 2.1.4). Low attack complexity means any caller with tensor access to the runtime can trigger this. Shared GPU clusters and multi-tenant inference services are highest risk.

Is CVE-2021-29609 actively exploited?

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

How to fix CVE-2021-29609?

1. Patch: Upgrade to TF 2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4. 2. Validate all incoming tensor shapes and indices at the application boundary before passing to SparseAdd — reject tensors where indices second dimension does not match the corresponding shape tensor. 3. Isolate TF inference workers in containers with no-new-privileges and seccomp profiles to contain blast radius. 4. Audit inference APIs and gRPC endpoints that accept sparse tensor formats from external callers. 5. Monitor for unexpected TF serving process crashes as a detection signal for exploitation attempts.

What systems are affected by CVE-2021-29609?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, inference endpoints.

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

CVE-2021-29609 has a CVSS v3.1 base score of 7.8 (HIGH). The EPSS exploitation probability is 0.02%.

Technical Details

NVD Description

TensorFlow is an end-to-end open source platform for machine learning. Incomplete validation in `SparseAdd` results in allowing attackers to exploit undefined behavior (dereferencing null pointers) as well as write outside of bounds of heap allocated data. The implementation(https://github.com/tensorflow/tensorflow/blob/656e7673b14acd7835dc778867f84916c6d1cac2/tensorflow/core/kernels/sparse_add_op.cc) has a large set of validation for the two sparse tensor inputs (6 tensors in total), but does not validate that the tensors are not empty or that the second dimension of `*_indices` matches the size of corresponding `*_shape`. This allows attackers to send tensor triples that represent invalid sparse tensors to abuse code assumptions that are not protected by validation. 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 adversary with access to a TensorFlow inference endpoint (TF Serving, custom gRPC API, or shared Jupyter environment) submits a crafted SparseTensor triple where the indices tensor shape does not match the corresponding shape tensor, or sends empty tensors. The SparseAdd kernel, lacking these validation checks, dereferences a null pointer or writes beyond heap-allocated bounds. At minimum this crashes the inference server (DoS); in a memory-unsafe runtime it enables heap exploitation for code execution on the ML host — from which the attacker can exfiltrate model weights, training data, or pivot to internal infrastructure.

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