CVE-2021-29566: Heap OOB access in tensorflow

tensorflow Updated 02 Oct 2025

Summary

21/05/2021
Yes i
Low
2.5

CVE-2021-29566: Heap OOB access in Dilation2DBackpropInput. 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-29566 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 Penetration testing for web, API and mobile 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 open-source machine learning framework developed by Google. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. However, a vulnerability has been discovered in TensorFlow that could potentially allow an attacker to write outside the bounds of heap allocated arrays.

Vulnerability Detail

The vulnerability, identified as CVE-2021-29566, specifically affects the Dilation2DBackpropInput function in TensorFlow. By passing invalid arguments to this function, an attacker can trigger a heap out-of-bounds (OOB) access. The issue arises due to a lack of validation before writing to the output array. While the loop indices for the out_backprop array are guaranteed to be within range, there are no similar guarantees for the in_backprop array. This vulnerability could lead to arbitrary memory corruption and potentially enable an attacker to execute arbitrary code.

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.1.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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 avoid passing invalid arguments to the Dilation2DBackpropInput function. It is important to ensure that the input arguments are valid and within the expected range. Here is an example of how to use the function safely:

import tensorflow as tf

input_tensor = tf.constant([1.1] * 81, shape=[3, 3, 3, 3], dtype=tf.float32)
filter = tf.constant([], shape=[0, 0, 3], dtype=tf.float32)
out_backprop = tf.constant([1.1] * 1062, shape=[3, 2, 59, 3], dtype=tf.float32)

try:
    tf.raw_ops.Dilation2DBackpropInput(
        input=input_tensor, filter=filter, out_backprop=out_backprop,
        strides=[1, 40, 1, 1], rates=[1, 56, 56, 1], padding='VALID'
    )
except Exception as e:
    print('Error:', e)

By handling any exceptions raised by the function, users can prevent the vulnerability from being exploited.

Conclusion

The vulnerability in TensorFlow has been addressed by the TensorFlow team. Users are advised to update to TensorFlow 2.5.0 or apply the relevant patches for earlier versions. It is important to ensure that valid arguments are passed to the Dilation2DBackpropInput function to prevent the vulnerability from being exploited. 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 machine learning framework developed by Google. It provides tools and resources for building and deploying machine learning models.

The vulnerability allows an attacker to write outside the bounds of heap allocated arrays, potentially leading to arbitrary memory corruption and the execution of arbitrary code.

The vulnerability has been fixed in TensorFlow 2.5.0. Users should update to this version or apply the relevant patches for earlier versions.

Users can avoid passing invalid arguments to the Dilation2DBackpropInput function as a temporary workaround.

Please consult the TensorFlow security guide for more information regarding the security model and how to contact the TensorFlow team with any issues or questions.

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.1.4 2.1.4
    pip install --upgrade "tensorflow==2.1.4"
  • >= 2.2.0, < 2.2.3 2.2.3
    pip install --upgrade "tensorflow==2.2.3"
  • >= 2.3.0, < 2.3.3 2.3.3
    pip install --upgrade "tensorflow==2.3.3"
  • >= 2.4.0, < 2.4.2 2.4.2
    pip install --upgrade "tensorflow==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