CVE-2021-29539: Segfault in tf.raw_ops.ImmutableConst in TensorFlow
Summary
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
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
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.
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.
No signup required · Results in about 60 seconds
Background
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow allows users to define and execute computational graphs, making it suitable for a wide range of applications in artificial intelligence and deep learning. However, a vulnerability has been discovered in the tf.raw_ops.ImmutableConst function, which can lead to a segmentation fault when certain data types are used.
Vulnerability Detail
The vulnerability arises when calling the tf.raw_ops.ImmutableConst function with a dtype of tf.resource or tf.variant. The implementation assumes that the tensor contents are pure scalars, leading to a segfault. This can have various ramifications, including crashes or unexpected behavior in TensorFlow applications that utilize this function. The vulnerability has been assigned a CVSS score of 2.5, indicating a low severity level.
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.1.42.1.4pip install --upgrade "tensorflow==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow==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 using tf.raw_ops.ImmutableConst in code, a workaround to prevent the segfault is to insert a filter for the dtype argument. By filtering out tf.resource and tf.variant data types, the vulnerability can be avoided. Here's an example of how to implement the workaround:
import tensorflow as tf
def safe_immutable_const(dtype, shape, memory_region_name):
if dtype not in [tf.resource, tf.variant]:
return tf.raw_ops.ImmutableConst(dtype=dtype, shape=shape, memory_region_name=memory_region_name)
else:
# Handle the unsupported data types
return None
By using the safe_immutable_const function instead of directly calling tf.raw_ops.ImmutableConst, the vulnerability can be mitigated.
Conclusion
The vulnerability in TensorFlow's tf.raw_ops.ImmutableConst function can lead to a segmentation fault when certain data types are used. It is recommended to update to TensorFlow version 2.5.0 or later to fix this vulnerability. Alternatively, users can utilize TensorFlow nightly packages after the mentioned commit. A workaround is also available by filtering out unsupported data types. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides tools and resources for building and deploying machine learning models.
tf.raw_ops.ImmutableConst is a TensorFlow function used to create an immutable constant tensor.
The vulnerability can result in a segmentation fault when certain data types are used with tf.raw_ops.ImmutableConst. This can lead to crashes or unexpected behavior in TensorFlow applications.
To fix this vulnerability, update to TensorFlow version 2.5.0 or later, which includes the patch. Alternatively, you can use TensorFlow nightly packages after the commit mentioned in the vulnerability details.
Yes, a workaround is available. By filtering out tf.resource and tf.variant data types when using tf.raw_ops.ImmutableConst, the vulnerability can be avoided.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.