CVE-2022-21731: Denial of Service Vulnerability in TensorFlow
Summary
CVE-2022-21731: Type confusion leading to segfault in Tensorflow. Affects tensorflow across 3 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
>= 2.7.0, < 2.7.1
Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-gpu · PyPI
- tensorflow-cpu · PyPI
The same CVE-2022-21731 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 is widely used in various domains, including research, industry, and academia. This vulnerability affects versions 2.5.2, 2.6.0, and 2.6.1 of TensorFlow.
Vulnerability Detail
The vulnerability in TensorFlow is related to the implementation of shape inference for the ConcatV2 operation. By exploiting a type confusion, an attacker can trigger a denial of service attack that leads to a segmentation fault. The issue arises from the translation of the axis argument into concat_dim in the ConcatShapeHelper helper function. The computation of min_rank based on concat_dim is used to validate the rank of the values tensor. However, due to a 32-bit value overflow, the error check is bypassed when min_rank becomes negative. This vulnerability can be exploited to crash TensorFlow applications, potentially leading to service disruption.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.5.32.5.3 -
>= 2.6.0, < 2.6.32.6.3 -
>= 2.7.0, < 2.7.12.7.1
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 modify the affected code to ensure that the axis argument passed to ConcatV2 is within the valid range. This can be achieved by adding appropriate bounds checking before invoking the ConcatV2 operation. Here is an example of how the code can be modified:
# Before
tf.concat([tensor1, tensor2], axis=axis)
# After
if axis >= 0 and axis < num_dimensions:
tf.concat([tensor1, tensor2], axis=axis)
else:
# Handle invalid axis value
...
Conclusion
The vulnerability in TensorFlow can be exploited to trigger a denial of service attack by causing a segmentation fault. Users are advised to upgrade to the patched versions or apply the provided workaround. For further assistance and support in 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.
This vulnerability allows an attacker to trigger a denial of service attack, potentially leading to service disruption by crashing TensorFlow applications.
Versions 2.5.2, 2.6.0, and 2.6.1 of TensorFlow are affected by this vulnerability.
To fix this vulnerability, upgrade to the patched versions: TensorFlow 2.5.3, TensorFlow 2.6.2, or TensorFlow 2.7.1. Follow the official TensorFlow documentation for upgrade instructions.
Yes, a temporary workaround is to add bounds checking for the axis argument before invoking the ConcatV2 operation. See the 'workaround' section for code examples.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.