CVE-2021-29565: TensorFlow: null ptr dereference crashes sparse ops

MEDIUM PoC AVAILABLE
Published May 14, 2021
CISO Take

This vulnerability allows any low-privileged local user (or remote attacker reaching TensorFlow ops through an application layer) to crash a TensorFlow process by passing an empty dense_shape tensor to SparseFillEmptyRows. Availability-only impact — no code execution or data leakage. Patch immediately to TF 2.5.0 or the backport releases; if patching is delayed, validate tensor inputs at the application boundary.

What is the risk?

Medium risk in isolation, but elevated in ML serving environments where untrusted inputs can reach TensorFlow ops through an API or data pipeline. CVSS 5.5 reflects local-only scope, but many production inference services effectively expose TF ops to external inputs through a thin application wrapper. No evidence of active exploitation; CWE-476 null pointer dereference is well-understood and exploitable by anyone who can craft a malformed tensor input.

What systems are affected?

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

Do you use TensorFlow? You're affected.

How severe is it?

CVSS 3.1
5.5 / 10
EPSS
0.2%
chance of exploitation in 30 days
Higher than 9% of all CVEs
Exploitation Status
Exploit Available
Exploitation: MEDIUM
Sophistication
Trivial
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 None
I None
A High

What should I do?

4 steps
  1. Patch: upgrade to TensorFlow 2.5.0, or apply cherry-pick patches to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4.

  2. Workaround: add input validation before calling SparseFillEmptyRows — assert dense_shape tensor is non-empty before passing to the op.

  3. Detection: monitor for process crashes or SIGABRT in TensorFlow serving processes; log and alert on malformed sparse tensor inputs at API boundaries.

  4. Containment: run TF inference processes in isolated containers with automatic restart — limits blast radius to availability without service-level outage.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.1.5 - AI System Robustness and Reliability
NIST AI RMF
MANAGE-2.2 - Mechanisms to sustain the value of AI systems in operation
OWASP LLM Top 10
LLM04 - Model Denial of Service

Frequently Asked Questions

What is CVE-2021-29565?

This vulnerability allows any low-privileged local user (or remote attacker reaching TensorFlow ops through an application layer) to crash a TensorFlow process by passing an empty dense_shape tensor to SparseFillEmptyRows. Availability-only impact — no code execution or data leakage. Patch immediately to TF 2.5.0 or the backport releases; if patching is delayed, validate tensor inputs at the application boundary.

Is CVE-2021-29565 actively exploited?

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

How to fix CVE-2021-29565?

1. Patch: upgrade to TensorFlow 2.5.0, or apply cherry-pick patches to 2.4.2 / 2.3.3 / 2.2.3 / 2.1.4. 2. Workaround: add input validation before calling SparseFillEmptyRows — assert dense_shape tensor is non-empty before passing to the op. 3. Detection: monitor for process crashes or SIGABRT in TensorFlow serving processes; log and alert on malformed sparse tensor inputs at API boundaries. 4. Containment: run TF inference processes in isolated containers with automatic restart — limits blast radius to availability without service-level outage.

What systems are affected by CVE-2021-29565?

This vulnerability affects the following AI/ML architecture patterns: training pipelines, model serving, feature engineering pipelines, recommendation system inference.

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

CVE-2021-29565 has a CVSS v3.1 base score of 5.5 (MEDIUM). The EPSS exploitation probability is 0.19%.

What is the AI security impact?

Affected AI Architectures

training pipelinesmodel servingfeature engineering pipelinesrecommendation system inference

MITRE ATLAS Techniques

AML.T0010.001 AI Software
AML.T0029 Denial of AI Service
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: A.6.1.5
NIST AI RMF: MANAGE-2.2
OWASP LLM Top 10: LLM04

What are the technical details?

Original Advisory

TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a null pointer dereference in the implementation of `tf.raw_ops.SparseFillEmptyRows`. This is because of missing validation(https://github.com/tensorflow/tensorflow/blob/fdc82089d206e281c628a93771336bf87863d5e8/tensorflow/core/kernels/sparse_fill_empty_rows_op.cc#L230-L231) that was covered under a `TODO`. If the `dense_shape` tensor is empty, then `dense_shape_t.vec<>()` would cause a null pointer dereference in the implementation of the op. 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 targeting an ML-powered recommendation system submits a crafted API request with an empty dense_shape parameter in the sparse feature tensor payload. The application passes this directly to tf.raw_ops.SparseFillEmptyRows without validation. TensorFlow dereferences a null pointer, crashing the inference worker. In a containerized deployment without auto-restart, this takes the inference endpoint offline. Repeated requests constitute a low-effort DoS with no rate limiting needed — a single malformed request triggers the crash.

Weaknesses (CWE)

CWE-476 — NULL Pointer Dereference: The product dereferences a pointer that it expects to be valid but is NULL.

  • [Implementation] For any pointers that could have been modified or provided from a function that can return NULL, check the pointer for NULL before use. When working with a multithreaded or otherwise asynchronous environment, ensure that proper locking APIs are used to lock before the check, and unlock when it has finished [REF-1484].
  • [Requirements] Select a programming language that is not susceptible to these issues.

Source: MITRE CWE corpus.

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Timeline

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

Related Vulnerabilities