CVE-2021-37639: TensorFlow - Null Pointer Dereference and Heap OOB Read Vulnerability
Summary
CVE-2021-37639: Null pointer dereference and heap OOB read in TensorFlow. Affects tensorflow across 3 version ranges.
>= 2.3.0, < 2.3.4
>= 2.4.0, < 2.4.3
>= 2.5.0, < 2.5.1
Fixed in 2.3.4, 2.4.3 or 2.5.1, 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-37639 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 building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. This vulnerability affects versions 2.3.0 to 2.6.0-rc2 of TensorFlow.
Vulnerability Detail
When restoring tensors via raw APIs in TensorFlow, if the tensor name is not provided, an attacker can exploit this by tricking TensorFlow into dereferencing a null pointer. Additionally, if the attacker provides some tensor names but not enough for a successful restoration, they can read memory outside the bounds of heap allocated data. The vulnerability lies in the implementation of the tensor restoration process, where the tensor list corresponding to the user-controlled tensor_name input is retrieved without proper validation. This can lead to undefined behavior, such as null pointer dereference or heap out-of-bounds read.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 2.3.0, < 2.3.42.3.4 -
>= 2.4.0, < 2.4.32.4.3 -
>= 2.5.0, < 2.5.12.5.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
A workaround for this vulnerability is to ensure that the tensor name is always provided when restoring tensors via raw APIs in TensorFlow. By explicitly specifying the tensor name, the null pointer dereference and heap out-of-bounds read can be avoided. Here is an example of how to provide the tensor name:
import tensorflow as tf
# Specify the tensor name
tensor_name = 'my_tensor'
# Restore the tensor
restored_tensor = tf.raw_ops.RestoreV2(tensor_name=tensor_name, ...)
Conclusion
The vulnerability in TensorFlow allows for null pointer dereference and heap out-of-bounds read. It is crucial to upgrade to the patched version once it is available to mitigate the risk. In the meantime, users can apply the provided workaround. 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 resources for building and deploying machine learning models.
Versions 2.3.0 to 2.6.0-rc2 of TensorFlow are affected by this vulnerability.
This vulnerability can lead to null pointer dereference or heap out-of-bounds read, which can be exploited by an attacker to potentially execute arbitrary code or disclose sensitive information.
Yes, the vulnerability has been patched in TensorFlow commit 9e82dce6e6bd1f36a57e08fa85af213e2b2f2622. The fix will be included in TensorFlow 2.6.0.
Yes, a workaround for this vulnerability is to always provide the tensor name when restoring tensors via raw APIs in TensorFlow.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.