CVE-2021-29571: Memory corruption in tensorflow
Summary
CVE-2021-29571: Memory corruption in DrawBoundingBoxesV2. 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 · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-29571 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 open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. The vulnerability identified as CVE-2021-29571 affects TensorFlow versions 0.0.0 to 2.1.4, 2.2.0 to 2.2.3, 2.3.0 to 2.3.3, and 2.4.0 to 2.4.2. This vulnerability can lead to memory corruption due to a flaw in the implementation of the DrawBoundingBoxesV2 function.
Vulnerability Detail
The vulnerability arises from a memory corruption issue in the DrawBoundingBoxesV2 function of TensorFlow. Attackers can exploit this vulnerability by providing specially crafted inputs to the function. The flaw occurs when the last element of the boxes input is less than 4, which is required by the function. This can result in reads and writes outside the bounds of heap allocated objects, leading to memory corruption. The impact of this vulnerability can vary depending on the specific use case, but it has the potential to cause instability, crashes, or even allow for remote code execution.
How To Fix
Latest published version: 2.21.0 as of 22 Oct 2026
pip install --upgrade "tensorflow==2.21.0"
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 2.1.42.1.4pip install --upgrade "tensorflow==2.1.4" -
>= 2.2.0, < 2.2.32.2.3pip install --upgrade "tensorflow==2.2.3" -
>= 2.3.0, < 2.3.32.3.3pip install --upgrade "tensorflow==2.3.3" -
>= 2.4.0, < 2.4.22.4.2pip install --upgrade "tensorflow==2.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 workaround, users can ensure that the boxes input passed to the DrawBoundingBoxesV2 function has a last dimension of at least 4. This can be achieved by padding the input with zeros or by modifying the input data to meet the required format. Here is an example of how to pad the boxes input using TensorFlow:
import tensorflow as tf
boxes = tf.pad(boxes, [[0, 0], [0, 0], [0, 4 - tf.shape(boxes)[-1]]])
Conclusion
The vulnerability identified as CVE-2021-29571 in TensorFlow can lead to memory corruption and has a CVSS score of 4.5. It is crucial to update to the patched versions of TensorFlow to mitigate this vulnerability. Users can also utilize the Vulert Playground (https://vulert.com/scanner) to check the vulnerability status of their applications. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for tensorflow →
FAQ
TensorFlow is an open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models.
The impact of this vulnerability can vary depending on the specific use case, but it has the potential to cause instability, crashes, or even allow for remote code execution.
To fix this vulnerability, it is recommended to update to one of the patched versions of TensorFlow: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4. Users can upgrade their TensorFlow installation using the package manager or by following the instructions provided by TensorFlow.
Yes, as a workaround, users can ensure that the boxes input passed to the DrawBoundingBoxesV2 function has a last dimension of at least 4. This can be achieved by padding the input with zeros or by modifying the input data to meet the required format.
You can use the Vulert Playground (https://vulert.com/scanner) without any signup to check the vulnerability status of your application. It analyzes your Pipfile.lock and alerts you in real-time for open-source vulnerabilities in your software.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.