CVE-2021-29523: Denial of Service in TensorFlow

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29523: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 5 version ranges.

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < 69c68ecbb24dff3fa0e46da0d16c821a2dd22d7c

Fixed in 4 releases; the minimum fixed version depends on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-29523 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. It supports both CPU and GPU computations, allowing for efficient training and inference on a wide range of hardware configurations.

Vulnerability Detail

The vulnerability identified as CVE-2021-29523 affects the TensorFlow package. It can be triggered by an attacker through a CHECK-fail in the tf.raw_ops.AddManySparseToTensorsMap function. The vulnerability arises from the implementation of the function, which uses the values specified in the sparse_shape parameter as dimensions for the output shape. However, the TensorShape constructor used in this implementation employs a legacy approach that relies on a CHECK operation. This operation triggers when the InitDims function returns a non-OK status, leading to a denial of service. The impact of this vulnerability can result in the disruption of TensorFlow-based applications, affecting their availability and potentially leading to financial losses or other adverse consequences.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==2.21.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.4.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a workaround, users can modify the affected code to use the BuildTensorShapeBase or AddDimWithStatus functions instead of the legacy TensorShape constructor. By using these alternative functions, the CHECK-failures can be prevented, mitigating the risk of a denial of service. Here is an example of how the code can be modified:

import tensorflow as tf

# Original code
shape = tf.TensorShape(sparse_shape)

# Modified code
shape = tf.TensorShape().BuildTensorShapeBase(sparse_shape)

Conclusion

The vulnerability identified as CVE-2021-29523 in TensorFlow can lead to a denial of service in TensorFlow-based applications. It is crucial to update to the latest available version of TensorFlow (2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4) to mitigate the risk. Additionally, modifying the affected code to use the BuildTensorShapeBase or AddDimWithStatus functions can serve as a workaround. Regularly updating software dependencies and following secure coding practices are essential to prevent similar vulnerabilities in the future. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive set of tools and resources for developing and deploying machine learning models.

This vulnerability can lead to a denial of service in TensorFlow-based applications, causing disruption and potential financial losses.

To fix this vulnerability, update your TensorFlow installation to the latest available version (2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4) using the command pip install --upgrade tensorflow-cpu.

Yes, you can modify the affected code to use the BuildTensorShapeBase or AddDimWithStatus functions instead of the legacy TensorShape constructor.

To prevent similar vulnerabilities, regularly update your software dependencies and apply security patches promptly. Stay informed about the latest security advisories and follow best practices for secure coding.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==2.21.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
    pip install --upgrade "tensorflow-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==2.4.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback