CVE-2021-37643: TensorFlow - Null Pointer Dereference in MatrixDiagPartOp
Summary
CVE-2021-37643: Null pointer dereference in MatrixDiagPartOp 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-37643 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. This vulnerability affects versions 2.3.0 to 2.6.0-rc2 of TensorFlow.
Vulnerability Detail
The vulnerability (CVE-2021-37643) in TensorFlow arises when the tf.raw_ops.MatrixDiagPartOp function is called without providing a valid padding value. This triggers a null pointer dereference if the input is empty or produces invalid behavior by ignoring all values after the first. The issue originates from the implementation of the function, which reads the first value from a tensor buffer without checking if the tensor has any values to read from. This vulnerability can lead to crashes, null pointer exceptions, or incorrect results in TensorFlow applications.
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
If updating TensorFlow is not immediately feasible, a possible workaround is to ensure that a valid padding value is provided when calling the tf.raw_ops.MatrixDiagPartOp function. This can be achieved by checking the input tensor for empty values before invoking the function. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
input_tensor = tf.constant([])
if tf.size(input_tensor) > 0:
result = tf.raw_ops.MatrixDiagPartOp(input=input_tensor, padding=1)
else:
result = None
Conclusion
In conclusion, the vulnerability (CVE-2021-37643) in TensorFlow can result in crashes, null pointer exceptions, or incorrect results in TensorFlow applications. It is recommended to update TensorFlow to version 2.6.0 or later to fix this vulnerability. If immediate update is not feasible, the provided workaround can be applied. 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 set of tools and resources for building and deploying machine learning models.
This vulnerability can lead to crashes, null pointer exceptions, or incorrect results in TensorFlow applications.
Versions 2.3.0 to 2.6.0-rc2 of TensorFlow are affected by this vulnerability.
To fix this vulnerability, update TensorFlow to version 2.6.0 or later. Alternatively, apply the provided workaround if immediate update is not possible.
You can find more information about this vulnerability in the GitHub commit 482da92095c4d48f8784b1f00dda4f81c28d2988 and the associated CVE-2021-37643.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.