CVE-2021-29535: TensorFlow Heap Buffer Overflow in QuantizedMul
Summary
CVE-2021-29535: Heap buffer overflow in QuantizedMul. 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 · PyPI
- tensorflow · PyPI
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29535 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 of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow is widely used in various industries and research domains due to its flexibility and scalability. However, a vulnerability has been discovered in TensorFlow that can lead to a heap buffer overflow in the QuantizedMul operation.
Vulnerability Detail
The vulnerability arises from the assumption made in the implementation of QuantizedMul that the four threshold arguments passed to it are always valid scalars. However, if any of these tensors is empty, accessing the element at position 0 results in a heap buffer overflow. An attacker can exploit this vulnerability by providing invalid thresholds for quantization. The impact of this vulnerability can be severe, potentially leading to remote code execution or denial of service attacks.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 2.1.42.1.4 -
>= 2.2.0, < 2.2.32.2.3 -
>= 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
As a temporary workaround, users can avoid passing empty tensors as thresholds to the QuantizedMul operation. It is important to validate the input tensors and ensure they contain valid values before invoking the operation. Here is an example of how to perform this validation in Python:
import tensorflow as tf
def safe_quantized_mul(a, b, min_a, max_a, min_b, max_b):
if a.size == 0 or b.size == 0:
raise ValueError('Input tensors must not be empty')
return tf.quantization.quantized_mul(a, b, min_a, max_a, min_b, max_b)
Conclusion
The heap buffer overflow vulnerability in TensorFlow's QuantizedMul operation can have severe consequences, including remote code execution and denial of service attacks. It is crucial for users to update their TensorFlow installations to the patched versions as soon as they become available. Regularly updating TensorFlow is also recommended to stay protected against the latest security vulnerabilities. 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 of tools and libraries for developing and deploying machine learning models.
QuantizedMul is an operation in TensorFlow that performs element-wise multiplication of two quantized tensors. It is commonly used in machine learning models that involve quantization.
An attacker can exploit this vulnerability by providing invalid thresholds for quantization when invoking the QuantizedMul operation. This can lead to a heap buffer overflow and potentially enable remote code execution or denial of service attacks.
This vulnerability affects TensorFlow versions 0 and above. Specifically, versions 2.1.4, 2.2.3, 2.3.3, and 2.4.2 are known to be affected. It is recommended to update to the patched versions as soon as they become available.
Yes, a temporary workaround is to ensure that the input tensors passed to the QuantizedMul operation are not empty. It is important to validate the input tensors and ensure they contain valid values before invoking the operation.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.