CVE-2021-29612: TensorFlow Heap Buffer Overflow in BandedTriangularSolve

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

CVE-2021-29612: TensorFlow is an end-to-end open source platform for machine learning. Affects tensorflow-cpu across 6 version ranges.

< 0ab290774f91a23bebe30a358fde4e53ab4876a0 < 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < ba6822bd7b7324ba201a28b2f278c29a98edbef2

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-29612 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 Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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. The vulnerability described here affects the TensorFlow package, specifically the tf.raw_ops.BandedTriangularSolve function.

Vulnerability Detail

The vulnerability in TensorFlow arises from a heap buffer overflow in the Eigen implementation of tf.raw_ops.BandedTriangularSolve. The implementation fails to properly validate the input tensors, allowing an attacker to trigger the overflow by providing empty tensors. Additionally, the use of the OP_REQUIRES macro in the implementation does not effectively handle errors, as callers of helper functions do not check the status before continuing. This vulnerability can be exploited by an attacker to execute arbitrary code or cause a denial of service.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

pip install --upgrade "tensorflow-cpu==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-cpu==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow-cpu==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow-cpu==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow-cpu==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 temporary workaround, users can ensure that the input tensors provided to tf.raw_ops.BandedTriangularSolve are not empty. This can be done by adding appropriate checks in the calling code to validate the input tensors before passing them to the vulnerable function. Here is an example of how to perform the check in Python:

import tensorflow as tf

# Assuming `input_tensor1` and `input_tensor2` are the input tensors
if input_tensor1.shape.num_elements() == 0 or input_tensor2.shape.num_elements() == 0:
    raise ValueError('Input tensors must not be empty')

# Call the vulnerable function
output_tensor = tf.raw_ops.BandedTriangularSolve(input_tensor1, input_tensor2)

It is important to note that this workaround only prevents the vulnerability if the input tensors are empty. Upgrading to the fixed versions of TensorFlow is still recommended.

Conclusion

In conclusion, the vulnerability in TensorFlow's tf.raw_ops.BandedTriangularSolve function allows for a heap buffer overflow, which can be exploited by an attacker to execute arbitrary code or cause a denial of service. The TensorFlow team has addressed this vulnerability in the latest versions, and users are advised to update their installations to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow-cpu →

Share this vulnerability

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.

This vulnerability allows an attacker to trigger a heap buffer overflow in TensorFlow, potentially leading to arbitrary code execution or denial of service.

The vulnerability affects TensorFlow versions 2.1.4 and above, including TensorFlow 2.5.0.

To fix this vulnerability, it is recommended to upgrade to one of the fixed versions of TensorFlow: TensorFlow 2.5.0, TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, or TensorFlow 2.1.4.

Yes, as a temporary workaround, users can ensure that the input tensors provided to tf.raw_ops.BandedTriangularSolve are not empty by adding appropriate checks in the calling code.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow-cpu.

How To Fix

Latest published version: 2.21.0 as of 22 Oct 2026

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