CVE-2021-29604: Vulnerability in TensorFlow
Summary
CVE-2021-29604: Division by zero in TFLite's implementation of hashtable lookup. 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-29604 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 community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow is widely used in various domains, including computer vision, natural language processing, and deep learning. However, a vulnerability has been discovered in the TFLite implementation of hashtable lookup.
Vulnerability Detail
The vulnerability in TensorFlow's TFLite implementation of hashtable lookup arises from a division by zero error. Specifically, the issue can be triggered when a crafted model is used, causing the values's first dimension to be zero. This division by zero error can lead to unexpected behavior or crashes in the application using TensorFlow. The vulnerability has been assigned the identifier CVE-2021-29604 and has a severity rating of Medium.
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 the vulnerability by ensuring that the values tensor's first dimension is not zero when using the TFLite hashtable lookup functionality. This can be achieved by validating the input data and handling cases where the first dimension is zero separately. Here is an example code snippet demonstrating the workaround:
import tensorflow as tf
# Validate the input data
if values.shape[0] == 0:
# Handle the case where the first dimension is zero
# ... (add your custom logic here)
else:
# Perform the hashtable lookup
result = tf.lookup.experimental.DenseHashTable.lookup(table, keys, values)
By explicitly checking and handling the case where the first dimension is zero, the vulnerability can be mitigated.
Conclusion
In conclusion, a vulnerability has been identified in TensorFlow's TFLite implementation of hashtable lookup. This vulnerability can be triggered by a crafted model, causing a division by zero error. The issue will be addressed in upcoming versions of TensorFlow, and users are advised to update to the fixed versions to ensure the security of their applications. 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, providing tools and libraries for building and deploying machine learning models.
TFLite is a lightweight version of TensorFlow designed for mobile and embedded devices.
The vulnerability arises from a division by zero error when a crafted model is used, causing the values's first dimension to be zero.
The vulnerability can lead to unexpected behavior or crashes in applications using TensorFlow's TFLite hashtable lookup functionality.
The vulnerability will be fixed in TensorFlow 2.5.0. Users are advised to update to the fixed versions once they are released.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.