CVE-2021-41204: TensorFlow CPU - Resource Tensor Deep Copy Segfault

tensorflow-cpu Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Unrated
Not published

CVE-2021-41204: TensorFlow is an open source platform for machine learning. Affects tensorflow-cpu 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 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 open source platform for machine learning. It provides a comprehensive ecosystem of tools, libraries, and community resources that enable researchers and developers to build and deploy machine learning models. TensorFlow's Grappler optimizer phase is responsible for optimizing the computational graph, improving performance and efficiency. However, in certain versions of TensorFlow, a vulnerability exists during the constant folding process in which a deep copy of a resource tensor is attempted. This violates the assumption that these tensors should not change and leads to a segmentation fault (segfault).

Vulnerability Detail

The vulnerability in TensorFlow's Grappler optimizer phase allows for a resource tensor to be deep copied, resulting in a segfault. This vulnerability can be exploited by an attacker to cause a denial-of-service (DoS) condition or potentially execute arbitrary code. The issue arises due to the incorrect handling of resource tensors during constant folding. By leveraging this vulnerability, an attacker could craft malicious inputs that trigger the segfault, leading to a crash or arbitrary code execution.

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.4.4 2.4.4
    pip install --upgrade "tensorflow-cpu==2.4.4"
  • >= 2.5.0, < 2.5.2 2.5.2
    pip install --upgrade "tensorflow-cpu==2.5.2"
  • >= 2.6.0, < 2.6.1 2.6.1
    pip install --upgrade "tensorflow-cpu==2.6.1"
  • >= 2.7.0rc0, < 2.7.0 2.7.0
    pip install --upgrade "tensorflow-cpu==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 specific workaround available for this vulnerability. However, users can mitigate the risk by ensuring that their TensorFlow applications do not process untrusted or malicious inputs. By validating and sanitizing input data, the likelihood of triggering the vulnerability can be reduced.

Conclusion

The vulnerability in TensorFlow's Grappler optimizer phase, which allows for a resource tensor to be deep copied, can lead to a segfault and potential denial-of-service or arbitrary code execution. Users are strongly advised to update their TensorFlow installations to the fixed versions mentioned above. By keeping TensorFlow up to date and following best practices for input validation, the risk of exploitation can be significantly reduced. For further support on vulnerability remediation, please 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 ecosystem of tools, libraries, and community resources.

The Grappler optimizer phase in TensorFlow is responsible for optimizing the computational graph, improving performance and efficiency.

Constant folding is a process in TensorFlow where constant operations are evaluated and replaced with their computed values to optimize the computational graph.

A resource tensor in TensorFlow represents a handle to a resource, such as a variable or a queue, that can be modified during the execution of a TensorFlow graph.

To update your TensorFlow installation to the fixed version, you can use the appropriate package manager or follow the installation instructions provided by the TensorFlow project.

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