CVE-2021-29583: TensorFlow FusedBatchNorm Heap Buffer Overflow

tensorflow Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Low
2.5

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

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < 6972f9dfe325636b3db4e0bc517ee22a159365c0

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-29583 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 developing and deploying machine learning models. TensorFlow includes various operations and functions to perform tasks such as data preprocessing, model training, and inference. One of these operations is tf.raw_ops.FusedBatchNorm, which is used for batch normalization in neural networks. Batch normalization is a technique that helps improve the training and performance of deep learning models by normalizing the inputs to each layer. However, the implementation of tf.raw_ops.FusedBatchNorm in TensorFlow is vulnerable to a heap buffer overflow, which can lead to undefined behavior and potential security risks.

Vulnerability Detail

The vulnerability in TensorFlow's tf.raw_ops.FusedBatchNorm arises from a lack of validation for the scale, offset, mean, and variance tensors. When these tensors are used as inputs to the operation, the implementation fails to check if they have the same number of elements as the number of channels in the input tensor x. This oversight allows for heap out-of-bounds reads when accessing the buffers backing these tensors. Additionally, if the tensors are empty, the validation process triggers and prevents undefined behavior by dereferencing null pointers. However, this still poses a security risk as it can lead to denial-of-service attacks or potential information leaks. The vulnerability affects TensorFlow versions 2.1.4 and below, 2.2.3 and below, 2.3.3 and below, and 2.4.2 and below.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"

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 manually validate the scale, offset, mean, and variance tensors before passing them to the tf.raw_ops.FusedBatchNorm operation. This can be done by checking if the number of elements in these tensors matches the number of channels in the input tensor x. If the tensors are empty, they should not be used as inputs to the operation. Here is an example of how to perform the validation in Python:

import tensorflow as tf

def validate_tensors(scale, offset, mean, variance, x):
    num_channels = x.shape[-1]
    if scale.shape[-1] != num_channels or offset.shape[-1] != num_channels:
        raise ValueError('Scale and offset tensors must have the same number of elements as the number of channels in x')
    if mean.shape[-1] != num_channels or variance.shape[-1] != num_channels:
        raise ValueError('Mean and variance tensors must have the same number of elements as the number of channels in x')

# Usage
scale = ...
offset = ...
mean = ...
variance = ...
x = ...

validate_tensors(scale, offset, mean, variance, x)

# Continue with the FusedBatchNorm operation
...```

Conclusion

The vulnerability in TensorFlow's tf.raw_ops.FusedBatchNorm can lead to heap buffer overflow and undefined behavior. It is crucial for users to update their TensorFlow installation to the latest stable version that includes the necessary patches. By following the recommended steps, developers can ensure the security and stability of their machine learning models.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides a comprehensive ecosystem of tools, libraries, and resources for developing and deploying machine learning models.

tf.raw_ops.FusedBatchNorm is an operation in TensorFlow that performs batch normalization on the input tensor. Batch normalization is a technique used in deep learning models to improve training and performance.

The vulnerability occurs due to a lack of validation for the scale, offset, mean, and variance tensors used as inputs to tf.raw_ops.FusedBatchNorm. If these tensors have a different number of elements than the number of channels in the input tensor, it can lead to heap buffer overflow and undefined behavior.

The vulnerability can lead to heap buffer overflow, which can result in undefined behavior and potential security risks. It can be exploited for denial-of-service attacks or information leaks.

To fix this vulnerability, it is recommended to upgrade to the latest stable version of TensorFlow, which includes the necessary patches. Developers can update their TensorFlow installation using the package manager or by manually downloading and installing the updated version from the official TensorFlow website.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow==2.4.3"

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