CVE-2021-29608: TensorFlow CPU - Lack of Validation in tf.raw_ops.RaggedTensorToTensor

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < b761c9b652af2107cfbc33efd19be0ce41daa33e < c4d7afb6a5986b04505aca4466ae1951686c80f6 < f94ef358bb3e91d517446454edff6535bcfe8e4a

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-29608 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 build and train neural networks, perform data preprocessing, and evaluate model performance. The package is widely used in various industries and research domains for a wide range of machine learning tasks.

Vulnerability Detail

The vulnerability (CVE-2021-29608) exists in the tf.raw_ops.RaggedTensorToTensor function of TensorFlow. Due to a lack of validation, an attacker can exploit an undefined behavior if input arguments are empty. The implementation of the function only checks that one of the tensors is not empty, but fails to validate the other ones. This oversight can lead to unexpected and potentially malicious behavior. Although there are some validations in place to prevent heap out-of-bounds access, these validations are disabled in release builds, rendering them ineffective. The vulnerability affects multiple versions of TensorFlow, including 2.1.4, 2.2.3, 2.3.3, 2.4.2, and prior versions. The TensorFlow team has addressed this issue and the fix will be included in TensorFlow 2.5.0.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==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 temporary workaround, users can manually validate the input arguments before calling the tf.raw_ops.RaggedTensorToTensor function. By ensuring that all input tensors are non-empty, users can mitigate the risk of triggering the undefined behavior. Here is an example of how to perform the validation in Python:

import tensorflow as tf

def safe_ragged_tensor_to_tensor(rt):
    if not rt.ragged_rank:
        raise ValueError('Input RaggedTensor must have ragged_rank > 0')
    if not rt.bounding_shape():
        raise ValueError('Input RaggedTensor must have non-empty bounding shape')
    return tf.raw_ops.RaggedTensorToTensor(rt)

Conclusion

The vulnerability (CVE-2021-29608) in TensorFlow's tf.raw_ops.RaggedTensorToTensor function can be exploited by an attacker if input arguments are empty. It is crucial for users to update their TensorFlow installations to version 2.5.0 or later once it is released to ensure the security and stability of their machine learning models and applications. In the meantime, users can apply a temporary workaround by manually validating the input arguments. 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.

The vulnerability allows an attacker to exploit an undefined behavior in the tf.raw_ops.RaggedTensorToTensor function of TensorFlow. This can potentially lead to unexpected and malicious behavior, compromising the integrity and security of machine learning models and applications built using TensorFlow.

The vulnerability affects TensorFlow versions 2.1.4, 2.2.3, 2.3.3, 2.4.2, and prior versions. It has been addressed in TensorFlow 2.5.0 and later versions.

Yes, as a temporary workaround, users can manually validate the input arguments before calling the tf.raw_ops.RaggedTensorToTensor function. By ensuring that all input tensors are non-empty, users can mitigate the risk of triggering the undefined behavior.

To fix the vulnerability, it is recommended to update TensorFlow to version 2.5.0 once it is released. This update will include the necessary validation checks in the tf.raw_ops.RaggedTensorToTensor function to prevent the undefined behavior when input arguments are empty.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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