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

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2021-29602: Division by zero in TFLite's implementation of DepthwiseConv. 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-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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

TensorFlow is an end-to-end open source platform for machine learning. It provides a comprehensive set of tools, libraries, and resources for developing and deploying machine learning models. The DepthwiseConv operator is a part of TensorFlow Lite, which is a lightweight version of TensorFlow designed for mobile and embedded devices. This operator performs depthwise convolution, a common operation in convolutional neural networks. It is used to apply a set of filters to input data, preserving the spatial dimensions while varying the number of channels. The vulnerability in the DepthwiseConv operator allows an attacker to craft a malicious model that triggers a division by zero error when the fourth dimension of the input is set to zero.

Vulnerability Detail

The vulnerability arises from a division by zero error in the implementation of the DepthwiseConv TFLite operator in TensorFlow. By providing a model with a fourth dimension of zero for the input, an attacker can trigger this error. The impact of this vulnerability can be severe, leading to crashes, denial of service, or potential exploitation of other vulnerabilities in the system. The vulnerability has been assigned the identifier CVE-2021-29602 and has a CVSSv3 score of 7.5 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H).

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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 in their models is always set to a non-zero value. This can be achieved by validating the input dimensions before passing them to the DepthwiseConv operator. Here is an example code snippet in Python that demonstrates this workaround:

import tensorflow as tf

# Validate input dimensions
input_shape = (batch_size, height, width, channels)
if input_shape[3] == 0:
    raise ValueError('Invalid input dimensions: fourth dimension cannot be zero')

# Perform depthwise convolution
output = tf.nn.depthwise_conv2d(input, filter, strides, padding)

By performing this validation, the division by zero error can be avoided.

Conclusion

The TensorFlow DepthwiseConv operator division by zero vulnerability (CVE-2021-29602) can be mitigated by upgrading to the latest patched version of TensorFlow. It is important to promptly apply the fix to ensure the security and stability of machine learning models. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

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

The DepthwiseConv operator is a part of TensorFlow Lite, which is a lightweight version of TensorFlow designed for mobile and embedded devices. It performs depthwise convolution, a common operation in convolutional neural networks.

The vulnerability arises from a division by zero error in the implementation of the DepthwiseConv operator. By providing a model with a fourth dimension of zero for the input, an attacker can trigger this error.

The vulnerability can lead to crashes, denial of service, or potential exploitation of other vulnerabilities in the system.

The vulnerability has been fixed in TensorFlow 2.5.0. Users are advised to upgrade to the latest patched version of TensorFlow to mitigate the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 2.1.4 2.1.4
  • >= 2.2.0, < 2.2.3 2.2.3
  • >= 2.3.0, < 2.3.3 2.3.3
  • >= 2.4.0, < 2.4.2 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