CVE-2021-29552: TensorFlow UnsortedSegmentJoin CHECK-failure
Summary
CVE-2021-29552: CHECK-failure in UnsortedSegmentJoin. 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-29552 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 that provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models. It is widely used in various domains for tasks such as image recognition, natural language processing, and recommendation systems. TensorFlow includes a feature called UnsortedSegmentJoin, which allows users to join multiple segments of a tensor based on segment IDs. This feature is commonly used in data processing and analysis pipelines.
Vulnerability Detail
The vulnerability, identified as CVE-2021-29552, affects the UnsortedSegmentJoin function in TensorFlow. An attacker can exploit this vulnerability by controlling the values of the num_segments tensor argument. The implementation of UnsortedSegmentJoin assumes that the num_segments tensor is a valid scalar, but if the tensor is empty, a CHECK condition is invalidated, leading to process termination. This vulnerability can be leveraged to cause a denial of service (DoS) attack. The impact of this vulnerability is relatively low, with a CVSS score of 2.5.
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
As a workaround, users can manually validate the num_segments tensor before passing it to the UnsortedSegmentJoin function. This can be done by checking the number of elements in the tensor and ensuring it is exactly one. Here is an example of how to implement this workaround in Python:
import tensorflow as tf
inputs = tf.constant([], dtype=tf.string)
segment_ids = tf.constant([], dtype=tf.int32)
num_segments = tf.constant([], dtype=tf.int32)
separator = ''
if tf.size(num_segments) != 1:
raise ValueError('num_segments tensor must contain exactly one element')
# Proceed with UnsortedSegmentJoin
# ...
By manually validating the num_segments tensor, users can prevent the CHECK failure and mitigate the vulnerability.
Conclusion
The vulnerability in TensorFlow's UnsortedSegmentJoin function has been addressed in the latest patched versions. Users are advised to update their installations to mitigate the risk of a denial of service attack. 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 that provides tools and resources for developing and deploying machine learning models.
UnsortedSegmentJoin is a feature in TensorFlow that allows users to join multiple segments of a tensor based on segment IDs. It is commonly used in data processing and analysis pipelines.
The impact of this vulnerability is relatively low, with a CVSS score of 2.5. It can be exploited to cause a denial of service (DoS) attack by controlling the num_segments tensor argument.
To fix this vulnerability, update your TensorFlow installation to one of the patched versions: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.
Yes, a workaround is to manually validate the num_segments tensor before passing it to the UnsortedSegmentJoin function. Check the number of elements in the tensor and ensure it is exactly one.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.