CVE-2021-29602: TensorFlow DepthwiseConv Operator Division by Zero Vulnerability

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

< 2.1.4 >= 2.2.0, < 2.2.3 >= 2.3.0, < 2.3.3 >= 2.4.0, < 2.4.2 < cbda3c6b2dbbd3fbdc482ff8c0170a78ec2e97d0

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-29602 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 Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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 operators, including the DepthwiseConv operator, which is used for depthwise separable convolution in neural networks. This operator is vulnerable to a division by zero error, which can be exploited by an attacker.

Vulnerability Detail

The vulnerability in the DepthwiseConv operator arises from a division by zero error in the implementation code. Specifically, the issue occurs when the fourth dimension of the input tensor is set to zero. An attacker can craft a malicious model that triggers this condition, potentially leading to a crash or other unintended behavior. The vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, 2.3.3, 2.2.3, and 2.1.4.

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 workaround, users can ensure that the fourth dimension of the input tensor is always set to a non-zero value. This can be achieved by validating the input data and adjusting the dimensions if necessary. Here is an example code snippet that demonstrates the workaround:

import tensorflow as tf

# Validate input tensor dimensions
if input.shape[3] == 0:
    input = tf.reshape(input, (input.shape[0], input.shape[1], input.shape[2], 1))

# Continue with normal operations
...

Conclusion

The TensorFlow DepthwiseConv operator division by zero vulnerability can be mitigated by upgrading to the latest version of TensorFlow or applying the provided patches. It is crucial for users to promptly address this vulnerability to ensure the security and stability of their TensorFlow-based machine learning applications. For further support and assistance with 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 set of tools and resources for developing and deploying machine learning models.

The DepthwiseConv operator is a part of TensorFlow's operator set and is used for depthwise separable convolution in neural networks.

This vulnerability can be exploited by an attacker to cause a division by zero error in the DepthwiseConv operator, potentially leading to a crash or other unintended behavior in TensorFlow-based applications.

The vulnerability affects TensorFlow versions ranging from 0 to 2.4.2, 2.3.3, 2.2.3, and 2.1.4.

To fix this vulnerability, users should upgrade their TensorFlow installations to version 2.5.0 or later. Alternatively, patches are available for TensorFlow versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4.

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