CVE-2021-29517: TensorFlow - Division by 0 in Conv3D Implementation

tensorflow Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2021-29517: Division by zero in Conv3D. 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-29517 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 for building and deploying machine learning models. TensorFlow is widely used in various industries and research fields for tasks such as image recognition, natural language processing, and recommendation systems. This vulnerability affects versions of TensorFlow ranging from 0 to 2.4.2, and it can be exploited by a malicious user to trigger a division by 0 in the Conv3D implementation.

Vulnerability Detail

The vulnerability arises from a modulo operation performed on user-controlled input in the Conv3D implementation of TensorFlow. When the fifth element of the 'filter' tensor is set to 0, a division by 0 occurs. Additionally, if the shape of the two tensors is invalid, it can trigger an Eigen assertion, leading to a program crash. This vulnerability can be exploited to cause denial of service (DoS) attacks or potentially execute arbitrary code.

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 validate the shape of the tensors before passing them to the Conv3D function. Additionally, it is important to ensure that the 'filter' tensor does not contain a 0 as its fifth element. Here is an example of how to perform the shape validation:

import tensorflow as tf

def validate_tensors(tensor1, tensor2):
    if tensor1.shape != tensor2.shape:
        raise ValueError('Invalid tensor shapes')

    # Rest of the code

validate_tensors(tensor1, tensor2)

Conclusion

The vulnerability in TensorFlow's Conv3D implementation can be exploited to trigger a division by 0 and potentially cause denial of service (DoS) attacks or arbitrary code execution. It is crucial to upgrade to the patched versions or apply the recommended workarounds to mitigate the risk. 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 ecosystem for building and deploying machine learning models.

This vulnerability can be exploited by a malicious user to trigger a division by 0 in the Conv3D implementation, potentially leading to denial of service (DoS) attacks or arbitrary code execution.

Versions of TensorFlow ranging from 0 to 2.4.2 are affected by this vulnerability.

To fix this vulnerability, it is recommended to upgrade to the patched versions available for TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4.

Yes, as a temporary workaround, users can validate the shape of the tensors before passing them to the Conv3D function and ensure that the 'filter' tensor does not contain a 0 as its fifth element.

Related vulnerabilities

Recent vulnerabilities recorded for tensorflow.

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