CVE-2021-29539: TensorFlow - Segfault in tf.raw_ops.ImmutableConst

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2021-29539: Segfault in tf.raw_ops.ImmutableConst. 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-29539 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive set 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 augmentation, and deploy models in various environments. It is widely used in both research and production settings.

Vulnerability Detail

The vulnerability (CVE-2021-29539) in TensorFlow arises when calling the tf.raw_ops.ImmutableConst function with a dtype of tf.resource or tf.variant. This triggers a segmentation fault (segfault) in the implementation because the code assumes that the tensor contents are pure scalars. The issue has been patched in the commit 4f663d4b8f0bec1b48da6fa091a7d29609980fa4 and will be included in TensorFlow 2.5.0. Nightly packages after this commit will also have the issue resolved. The vulnerability can lead to crashes or instability in TensorFlow applications that use tf.raw_ops.ImmutableConst with the mentioned dtype values.

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

If you are unable to update TensorFlow immediately, you can apply a workaround by filtering the dtype argument when using tf.raw_ops.ImmutableConst. This can be done by checking the dtype value before calling the function and only allowing valid scalar types. Here is an example workaround in Python:

def safe_immutable_const(value, dtype):
    valid_dtypes = [tf.float32, tf.float64, tf.int32, tf.int64, tf.bool, tf.string]
    if dtype in valid_dtypes:
        return tf.raw_ops.ImmutableConst(value=value, dtype=dtype)
    else:
        raise ValueError('Invalid dtype')

Conclusion

In conclusion, the vulnerability (CVE-2021-29539) in TensorFlow can result in a segfault when using tf.raw_ops.ImmutableConst with a dtype of tf.resource or tf.variant. It is recommended to update TensorFlow to version 2.5.0 or later, or use TensorFlow nightly packages after the commit 4f663d4b8f0bec1b48da6fa091a7d29609980fa4 to mitigate the issue. If you are unable to update immediately, you can apply a workaround by filtering the dtype argument. 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 tools and libraries for building and deploying machine learning models.

The vulnerability can lead to crashes or instability in TensorFlow applications that use tf.raw_ops.ImmutableConst with a dtype of tf.resource or tf.variant.

To fix the vulnerability, update TensorFlow to version 2.5.0 or later once it is released. Alternatively, use TensorFlow nightly packages after the commit 4f663d4b8f0bec1b48da6fa091a7d29609980fa4.

Yes, you can apply a workaround by filtering the dtype argument when using tf.raw_ops.ImmutableConst. Check the dtype value and only allow valid scalar types.

You can find more information about this vulnerability in the official TensorFlow documentation and the CVE entry (CVE-2021-29539).

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