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.

Risk Assessment

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.

Affected Systems

Package Ecosystem Vulnerable Range Patched
tensorflow pip No patch
195.0K OpenSSF 7.2 3.7K dependents Pushed today 4% patched ~1372d to patch Full package profile →

Do you use tensorflow? You're affected.

Severity & Risk

CVSS 3.1
5.5 / 10
EPSS
0.0%
chance of exploitation in 30 days
Higher than 11% 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, 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 None
I None
A High

Recommended Action

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.

Classification

Compliance Impact

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

Technical Details

NVD Description

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)

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