CVE-2021-41202: TensorFlow CPU - Integer Overflow in tf.range Kernel

tensorflow-cpu Updated 02 Oct 2025

Summary

05/11/2021
Yes i
Unrated
Not published

CVE-2021-41202: TensorFlow is an open source platform for machine learning. Affects tensorflow-cpu across 6 version ranges.

< 1b0e0ec27e7895b9985076eab32445026ae5ca94 < 2.4.4 >= 2.5.0, < 2.5.2 >= 2.6.0, < 2.6.1 >= 2.7.0rc0, < 2.7.0 < 6d94002a09711d297dbba90390d5482b76113899

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-41202 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 resources for developing and deploying machine learning models. TensorFlow is widely used in various domains, including research, industry, and academia. The TensorFlow CPU package, available on PyPI, is a specific distribution of TensorFlow optimized for CPU usage. It allows users to leverage the power of TensorFlow on systems without GPU support.

Vulnerability Detail

The vulnerability (CVE-2021-41202) exists in the TensorFlow CPU package. It arises when calculating the size of the output within the tf.range kernel. The issue stems from a conditional statement of type int64 = condition ? int64 : double. Due to C++ implicit conversion rules, both branches of the condition are cast to double, resulting in truncation before assignment. This leads to integer overflows, which can have various consequences depending on the specific usage of tf.range. An attacker could potentially exploit this vulnerability to cause unexpected behavior, crashes, or even execute arbitrary code.

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

As this vulnerability has been fixed in the latest versions of TensorFlow CPU, there is no specific workaround available. Users are strongly encouraged to update to the fixed versions to ensure the security and stability of their TensorFlow installations.

Conclusion

The vulnerability (CVE-2021-41202) in the TensorFlow CPU package poses a risk of integer overflows, potentially leading to unexpected behavior or even arbitrary code execution. Users should update their TensorFlow CPU package to one of the fixed versions (2.7.0, 2.6.1, 2.5.2, or 2.4.4) to mitigate this vulnerability. For further assistance or support in 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 and libraries.

The TensorFlow CPU package is a specific distribution of TensorFlow optimized for CPU usage, allowing users to run TensorFlow on systems without GPU support.

This vulnerability can lead to integer overflows, potentially causing unexpected behavior, crashes, or even enabling arbitrary code execution.

To fix this vulnerability, update your TensorFlow CPU package to one of the fixed versions: TensorFlow 2.7.0, TensorFlow 2.6.1, TensorFlow 2.5.2, or TensorFlow 2.4.4.

No, there is no specific workaround available. It is recommended to update to the fixed versions of TensorFlow CPU.

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