CVE-2021-41220: Use after free / memory leak in TensorFlow
Summary
CVE-2021-41220: Use after free / memory leak in CollectiveReduceV2. Affects tensorflow versions >= 2.6.0, < 2.6.1. Fixed in 2.6.1. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-cpu · PyPI
- tensorflow-gpu · PyPI
The same CVE-2021-41220 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
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 industries and research domains for tasks such as image recognition, natural language processing, and recommendation systems. However, a vulnerability has been discovered in the CollectiveReduceV2 function of TensorFlow, which can lead to a use after free and memory leak issue.
Vulnerability Detail
The CollectiveReduceV2 function in TensorFlow's async implementation suffers from a use after free and memory leak vulnerability. This vulnerability arises due to the asynchronous computation and the incorrect handling of objects that have been std::move()d from. The issue can result in undefined behavior, including crashes, std::bad_alloc exceptions, or memory leaks. An attacker could potentially exploit this vulnerability to execute arbitrary code, cause a denial of service, or leak sensitive information.
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 version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.6.1
This is the first release that contains the fix.
pip install --upgrade "tensorflow==2.6.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no specific workaround provided for this vulnerability. It is recommended to apply the patch or upgrade to the fixed version of TensorFlow as mentioned in the 'how_to_fix' section.
Conclusion
The use after free and memory leak vulnerability in TensorFlow's CollectiveReduceV2 function can have serious consequences, including crashes, denial of service, and information leakage. It is crucial to upgrade to the fixed version or apply the provided patch to mitigate the vulnerability. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for tensorflow →
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 can lead to a use after free and memory leak issue in TensorFlow, which can result in crashes, denial of service, or information leakage.
You can fix this vulnerability by upgrading to TensorFlow version 2.7.0 or applying the patch provided in the 'how_to_fix' section.
No specific workaround is available for this vulnerability. It is recommended to apply the patch or upgrade to the fixed version of TensorFlow.
This vulnerability was reported by members of the Aivul Team from Qihoo 360.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.