CVE-2021-29538: TensorFlow - Division by Zero Denial of Service

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2021-29538: Division by zero in Conv2DBackpropFilter. 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-29538 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 ecosystem of tools, libraries, and resources for developing and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. It supports a wide range of platforms and devices, making it accessible and versatile for different applications. However, a vulnerability has been discovered in TensorFlow that can lead to a denial of service attack.

Vulnerability Detail

The vulnerability (CVE-2021-29538) in TensorFlow arises from a division by zero error in the Conv2DBackpropFilter function. The implementation of this function computes a divisor based on user-provided data, specifically the shape of the tensors given as arguments. If all shapes are empty, the work_unit_size becomes 0. However, there is no check for this case before division, resulting in a runtime exception. An attacker can exploit this vulnerability by crafting inputs that trigger the division by zero, causing the TensorFlow application to crash. This can lead to a denial of service, disrupting the availability of the affected system. The vulnerability has a medium severity rating.

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 temporary workaround, users can implement input validation to check for empty shapes before invoking the Conv2DBackpropFilter function. By ensuring that at least one shape is non-empty, the division by zero error can be avoided. Here is an example code snippet in Python:

import tensorflow as tf

# Validate input shapes
if not any(shape for shape in input_shapes):
    raise ValueError('At least one input shape must be non-empty')

# Invoke Conv2DBackpropFilter function
output = tf.nn.conv2d_backprop_filter(...)

By performing this validation, the vulnerability can be mitigated until the updated versions of TensorFlow are installed.

Conclusion

The vulnerability in TensorFlow (CVE-2021-29538) can lead to a denial of service attack by triggering a division by zero error. It is crucial to update to the latest patched versions of TensorFlow to mitigate this vulnerability. In the meantime, implementing input validation can serve as a temporary workaround. For further support on 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 resources for developing and deploying machine learning models.

This vulnerability can be exploited by an attacker to cause a denial of service, potentially disrupting the availability of the affected system.

The vulnerability can be fixed by updating to the latest patched versions of TensorFlow, including TensorFlow 2.5.0 and the backported versions for earlier releases.

Yes, a temporary workaround is to implement input validation to check for empty shapes before invoking the vulnerable function.

The updated versions of TensorFlow can be obtained from the official TensorFlow website or through package managers.

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