CVE-2021-29571: Memory corruption in tensorflow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
4.5

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback