CVE-2021-29566: TensorFlow-CPU - Out-of-bounds Write in Dilation2DBackpropInput

tensorflow-cpu Updated 02 Oct 2025

Summary

14/05/2021
Yes i
Unrated
Not published

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

>= 2.2.0, < 2.3.0rc0 < 2.2.0rc0 >= 2.3.0, < 2.3.4 >= 2.4.0, < 2.4.3 < 3f6fe4dfef6f57e768260b48166c27d148f3015f

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 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-CPU is a specific package that focuses on running TensorFlow on CPUs. It is widely used in various industries and research fields for machine learning tasks.

Vulnerability Detail

The vulnerability (CVE-2021-29566) exists in the tf.raw_ops.Dilation2DBackpropInput function of TensorFlow-CPU. By passing invalid arguments to this function, an attacker can trigger an out-of-bounds write operation outside the bounds of heap allocated arrays. The implementation of the function does not properly validate the input arguments before writing to the output array. While the loop indices for out_backprop are bounded by the size of the array, there are no similar guarantees for in_backprop. This vulnerability can be exploited to overwrite memory and potentially lead to arbitrary code execution. The issue has been identified and a fix will be included in TensorFlow 2.5.0. Additionally, the fix will be backported to TensorFlow 2.4.2, TensorFlow 2.3.3, TensorFlow 2.2.3, and TensorFlow 2.1.4, as these versions are also affected and within the supported range.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==2.4.3"

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, you can consider implementing input validation checks in your code before calling the tf.raw_ops.Dilation2DBackpropInput function. By validating the input arguments and ensuring they are within the expected range, you can mitigate the risk of triggering the out-of-bounds write vulnerability. Here's an example of how you can perform input validation in Python:

import tensorflow as tf

def safe_dilation_backprop_input(out_backprop, filter, strides, padding, dilations, input_shape):
    h_out, w_out = out_backprop.shape[1], out_backprop.shape[2]
    h_in_max = input_shape[1] + (filter.shape[0] - 1) * dilations[0] - 2 * padding[0]
    w_in_max = input_shape[2] + (filter.shape[1] - 1) * dilations[1] - 2 * padding[1]
    if h_out > h_in_max or w_out > w_in_max:
        raise ValueError('Invalid output shape')
    return tf.raw_ops.Dilation2DBackpropInput(out_backprop, filter, strides, padding, dilations, input_shape)

Conclusion

The vulnerability (CVE-2021-29566) in TensorFlow-CPU's tf.raw_ops.Dilation2DBackpropInput function allows an attacker to write outside the bounds of heap allocated arrays, potentially leading to arbitrary code execution. It is crucial to update TensorFlow-CPU to the patched versions or upgrade to TensorFlow-CPU 2.5.0 once it is released to mitigate this vulnerability. Implementing input validation checks in your code can also provide temporary protection. For further support and assistance in vulnerability remediation, you can 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. It is widely used in various industries and research fields.

TensorFlow-CPU is a specific package that focuses on running TensorFlow on CPUs. It is optimized for CPU performance and does not require GPU acceleration. It is commonly used in environments where GPU resources are limited or not available.

This vulnerability allows an attacker to write outside the bounds of heap allocated arrays by passing invalid arguments to the tf.raw_ops.Dilation2DBackpropInput function. By exploiting this vulnerability, an attacker can potentially overwrite memory and execute arbitrary code, leading to a variety of security risks.

The vulnerability affects TensorFlow-CPU versions 2.4.2, 2.3.3, 2.2.3, and 2.1.4. These versions are within the supported range and will receive a backported fix. It is recommended to update to the patched versions or upgrade to TensorFlow-CPU 2.5.0 once it is released.

To mitigate the risk, it is recommended to update TensorFlow-CPU to the patched versions or upgrade to TensorFlow-CPU 2.5.0 once it is released. Additionally, you can implement input validation checks in your code before calling the vulnerable function to ensure the input arguments are within the expected range.

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.2.0rc0 2.2.0rc0
    pip install --upgrade "tensorflow-cpu==2.2.0rc0"
  • >= 2.2.0, < 2.3.0rc0 2.3.0rc0
    pip install --upgrade "tensorflow-cpu==2.3.0rc0"
  • >= 2.3.0, < 2.3.4 2.3.4
    pip install --upgrade "tensorflow-cpu==2.3.4"
  • >= 2.4.0, < 2.4.3 2.4.3
    pip install --upgrade "tensorflow-cpu==2.4.3"

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