CVE-2021-29521: TensorFlow - Negative Dense Shape in SparseCountSparseOutput Leads to Segmentation Fault
Summary
CVE-2021-29521: Segfault in SparseCountSparseOutput. Affects tensorflow across 2 version ranges.
>= 2.3.0, < 2.3.3
>= 2.4.0, < 2.4.2
Fixed in 2.3.3 or 2.4.2, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29521 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 end-to-end open source platform for machine learning. It provides a comprehensive ecosystem for building and deploying machine learning models. TensorFlow is widely used in various industries and research domains due to its flexibility, scalability, and extensive library of pre-built models and tools. However, a vulnerability has been identified in TensorFlow that can lead to a segmentation fault when specifying a negative dense shape in the tf.raw_ops.SparseCountSparseOutput function.
Vulnerability Detail
The vulnerability arises from a flaw in the implementation of the tf.raw_ops.SparseCountSparseOutput function. When a negative dense shape is provided, the implementation assumes that the first element of the dense shape is always positive. This assumption is used to initialize a BatchedMap<T> data structure, which is a vector of absl::flat_hash_map<int64,T>. However, if the shape tensor has more than one element, num_batches is the first value in shape. As a result, the implementation breaks the invariants of the std::vector and throws a segmentation fault. An attacker could potentially exploit this vulnerability to cause a denial of service or execute arbitrary code.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 2.3.0, < 2.3.32.3.3 -
>= 2.4.0, < 2.4.22.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
There is no specific workaround provided for this vulnerability. The recommended approach is to apply the fix by upgrading to the patched versions of TensorFlow.
Conclusion
The vulnerability in TensorFlow that allows a segmentation fault when specifying a negative dense shape in tf.raw_ops.SparseCountSparseOutput has been identified and fixed in TensorFlow 2.5.0. It is recommended to upgrade to the patched versions of TensorFlow to mitigate the risk of exploitation. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem for building and deploying machine learning models.
The vulnerability can lead to a segmentation fault, potentially causing a denial of service or enabling arbitrary code execution.
To fix this vulnerability, upgrade to TensorFlow 2.5.0 or apply the fix by upgrading to TensorFlow 2.4.2 or TensorFlow 2.3.3.
There is no specific workaround provided. It is recommended to apply the fix by upgrading to the patched versions of TensorFlow.
You can find more information about this vulnerability in the official TensorFlow documentation and the CVE entry.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.