CVE-2021-29529: TensorFlow Heap Buffer Overflow in tf.raw_ops.QuantizedResizeBilinear
Summary
CVE-2021-29529: Heap buffer overflow caused by rounding. 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-29529 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 set of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in the tf.raw_ops.QuantizedResizeBilinear function, which can lead to a heap buffer overflow.
Vulnerability Detail
The vulnerability in tf.raw_ops.QuantizedResizeBilinear arises from a float rounding error that results in an off-by-one error in accessing image elements. The implementation of the function computes upper and lower bounds for interpolation by ceiling and flooring a floating-point value. In some cases, the upper bound can be smaller than the lower bound, causing the lower bound to point outside of the image. This leads to a heap buffer overflow in the interpolation code. An attacker can exploit this vulnerability by manipulating input values to trigger the heap buffer overflow. The impact of this vulnerability can be severe, potentially allowing an attacker to execute arbitrary code or cause a denial of service.
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, developers can implement input validation and sanitization to ensure that the input values passed to tf.raw_ops.QuantizedResizeBilinear are within the expected range. This can help prevent the triggering of the heap buffer overflow. Here is an example of how input validation can be implemented in Python:
def validate_input(value):
if value < 0 or value > 255:
raise ValueError('Input value must be between 0 and 255')
# Example usage
input_value = get_input_value()
validate_input(input_value)
# Call to tf.raw_ops.QuantizedResizeBilinear
Conclusion
The vulnerability in TensorFlow's tf.raw_ops.QuantizedResizeBilinear function can lead to a heap buffer overflow, potentially allowing an attacker to execute arbitrary code or cause a denial of service. It is crucial to update to the fixed version (TensorFlow 2.5.0) as soon as it becomes available. In the meantime, implementing input validation and sanitization can help mitigate the risk. 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 tools and resources for building and deploying machine learning models.
This vulnerability can lead to a heap buffer overflow, which can potentially allow an attacker to execute arbitrary code or cause a denial of service.
The fix for this vulnerability will be included in TensorFlow 2.5.0. It is recommended to update to the fixed version as soon as it becomes available.
As a temporary workaround, developers can implement input validation and sanitization to prevent the triggering of the heap buffer overflow.
For more information about this vulnerability, you can refer to the official CVE entry (CVE-2021-29529) or the TensorFlow GitHub repository.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.