CVE-2021-41204: TensorFlow - Segfault Due to Deep Copy of Resource Tensor

tensorflow Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Moderate
5.5

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

< 2.4.4 >= 2.5.0, < 2.5.2 >= 2.6.0, < 2.6.1 >= 2.7.0rc0, < 2.7.0 < 7731e8dfbe4a56773be5dc94d631611211156659

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-41204 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 platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and resources for building and deploying machine learning models. TensorFlow's Grappler optimizer phase is responsible for optimizing the computational graph of a TensorFlow model. During this phase, constant folding is performed to optimize the execution of the graph by folding constant operations. However, in affected versions of TensorFlow, constant folding may attempt to deep copy a resource tensor, resulting in a segmentation fault (segfault). Resource tensors are not supposed to change, making this behavior a vulnerability.

Vulnerability Detail

The vulnerability in TensorFlow arises from the incorrect handling of resource tensors during constant folding. When constant folding is performed, a deep copy of a resource tensor is attempted, which leads to a segfault. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition or potentially execute arbitrary code. The impact of this vulnerability depends on the context in which TensorFlow is used and the privileges of the user running the affected TensorFlow application.

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.4.4 2.4.4
    pip install --upgrade "tensorflow==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow==2.7.0"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

There is no known workaround for this vulnerability. It is recommended to apply the fix by upgrading to a fixed version of TensorFlow.

Conclusion

The vulnerability in TensorFlow, identified as CVE-2021-41204, allows for a segfault due to the incorrect handling of resource tensors during constant folding. This vulnerability can be mitigated by upgrading to a fixed version of TensorFlow. It is recommended to upgrade to TensorFlow 2.7.0 or later, or apply the fix by upgrading to one of the backported versions within the supported range. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for tensorflow →

Share this vulnerability

FAQ

TensorFlow is an open source platform for machine learning that provides tools and libraries for building and deploying machine learning models.

The Grappler optimizer phase in TensorFlow is responsible for optimizing the computational graph of a TensorFlow model. It performs various optimizations, including constant folding.

Constant folding is an optimization technique in TensorFlow where constant operations in the computational graph are evaluated and replaced with their computed values.

Resource tensors in TensorFlow are tensors that represent resources, such as variables or GPU memory. They are used to manage and allocate resources during the execution of a TensorFlow model.

This vulnerability can lead to a segmentation fault (segfault) in TensorFlow, resulting in a denial-of-service (DoS) condition or potential execution of arbitrary code. The impact depends on the context and privileges of the affected TensorFlow application.

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.4.4 2.4.4
    pip install --upgrade "tensorflow==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow==2.7.0"

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