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

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
High
Not published

CVE-2021-29608: Heap OOB and null pointer dereference in RaggedTensorToTensor. Affects tensorflow across 4 version ranges.

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

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 Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive set of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various industries and research fields for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in TensorFlow that can be exploited due to a lack of validation in the tf.raw_ops.RaggedTensorToTensor function.

Vulnerability Detail

The vulnerability arises from the incomplete validation in the tf.raw_ops.RaggedTensorToTensor function. Specifically, the implementation of this function fails to validate all input arguments when they are empty. While the implementation checks that one of the tensors is not empty, it does not validate the other tensors. This oversight can lead to undefined behavior and potential security risks. Although there are some validations in place to prevent heap out-of-bounds access, these validations are ineffective in release builds, rendering them useless. An attacker can exploit this vulnerability to execute arbitrary code, potentially compromising the integrity, confidentiality, and availability of the affected system. The vulnerability has been assigned the identifier CVE-2021-29608.

How To Fix

Fixed versions by release line

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

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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 temporary workaround, users can manually validate the input arguments before passing them to the tf.raw_ops.RaggedTensorToTensor function. By ensuring that all input tensors are non-empty, the vulnerability can be mitigated. Here is an example of how to perform the validation in Python:

import tensorflow as tf

def safe_ragged_tensor_to_tensor(inputs):
    for tensor in inputs:
        if tf.size(tensor) == 0:
            raise ValueError('Input tensor cannot be empty')
    return tf.raw_ops.RaggedTensorToTensor(inputs)

Conclusion

The lack of validation in the tf.raw_ops.RaggedTensorToTensor function in TensorFlow can lead to undefined behavior and potential security risks. It is crucial for users to update to the latest patched version of TensorFlow as soon as it becomes available. In the meantime, implementing the provided workaround can help mitigate the vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides tools and libraries for building and deploying machine learning models.

This vulnerability allows an attacker to exploit undefined behavior in TensorFlow, potentially leading to arbitrary code execution and compromising the security of the affected system.

The vulnerability affects TensorFlow versions 0 and later. Specifically, versions 2.1.4, 2.2.3, 2.3.3, 2.4.2, and earlier versions are vulnerable.

Yes, the fix for this vulnerability will be included in TensorFlow 2.5.0. Backported fixes will also be available for TensorFlow 2.4.2, 2.3.3, 2.2.3, and 2.1.4.

To protect your system, it is recommended to update to the latest patched version of TensorFlow as soon as it becomes available. Additionally, you can implement the provided workaround to mitigate the vulnerability temporarily.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

How To Fix

Fixed versions by release line

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

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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