CVE-2021-29513: TensorFlow - Type Confusion Vulnerability

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

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

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < 030af767d357d1b4088c4a25c72cb3906abac489

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-29513 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

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 allows users to perform various operations on tensors, which are multi-dimensional arrays. These operations are typically performed on numeric tensors. However, calling TensorFlow operations with tensors of non-numeric types can lead to null pointer dereferences. This vulnerability arises due to a type confusion in the conversion from Python arrays to C++ arrays within TensorFlow.

Vulnerability Detail

The type confusion vulnerability in TensorFlow can be exploited when non-numeric tensors are passed to operations that expect numeric tensors. This can result in null pointer dereferences, leading to crashes or potential code execution vulnerabilities. An attacker could potentially craft malicious inputs to trigger this vulnerability and compromise the integrity or availability of the TensorFlow application. The vulnerability affects versions of TensorFlow up to 2.4.3.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"

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 ensure that only numeric tensors are passed to TensorFlow operations that expect numeric inputs. This can be achieved by validating the input tensors before passing them to the operations. Here is an example of how to validate and convert a Python array to a numeric tensor in TensorFlow:

import tensorflow as tf

def validate_and_convert_array(array):
    if not isinstance(array, (list, tuple)):
        raise ValueError('Input must be a list or tuple')
    if not all(isinstance(element, (int, float)) for element in array):
        raise ValueError('Input must contain only numeric elements')
    return tf.convert_to_tensor(array)

# Example usage
array = [1, 2, 3]
numeric_tensor = validate_and_convert_array(array)

Conclusion

The type confusion vulnerability in TensorFlow can be mitigated by upgrading to one of the fixed versions. It is important to keep software dependencies up to date to ensure the security and stability of machine learning applications. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

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

A tensor in TensorFlow is a multi-dimensional array that represents data used in machine learning operations. Tensors can have any number of dimensions and can contain numeric or non-numeric values.

The type confusion vulnerability in TensorFlow occurs when non-numeric tensors are passed to operations that expect numeric tensors. This can lead to null pointer dereferences and potential crashes or code execution vulnerabilities.

The type confusion vulnerability in TensorFlow can potentially be exploited by an attacker to compromise the integrity or availability of the TensorFlow application. This could lead to crashes, data corruption, or unauthorized code execution.

To fix the vulnerability, it is recommended to upgrade to one of the fixed versions of TensorFlow (2.5.0, 2.4.2, 2.3.3, 2.2.3, or 2.1.4). Users can update their TensorFlow installation using the package manager or by manually downloading and installing the updated version from the TensorFlow GitHub repository.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow==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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"

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