CVE-2022-23563: TensorFlow Insecure Temporary File Vulnerability
Summary
CVE-2022-23563: Insecure temporary file in Tensorflow. Affects tensorflow across 3 version ranges.
< 2.5.3
>= 2.6.0, < 2.6.3
>= 2.7.0, < 2.7.1
Fixed in 2.5.3, 2.6.3 or 2.7.1, depending on the release line you run. How to fix ↓
Also tracked for
- tensorflow · Bitnami
- tensorflow-gpu · PyPI
- tensorflow-cpu · PyPI
The same CVE-2022-23563 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 library widely used for various applications, including deep learning and neural networks. It provides a comprehensive ecosystem for building and deploying machine learning models. However, it has been found to have a vulnerability related to the creation of temporary files, which can lead to security risks if not addressed.
Vulnerability Detail
The vulnerability arises from TensorFlow's use of the tempfile.mktemp function to create temporary files. This method is susceptible to a Time-of-Check to Time-of-Use (TOC/TOU) attack, where an attacker can create a file with the same name between the time the filename is checked and the time the file is created. This can lead to unauthorized access or manipulation of sensitive data. Additionally, there are instances where TensorFlow intended to create a temporary directory instead of a file, which further complicates the issue.
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.5.32.5.3pip install --upgrade "tensorflow==2.5.3" -
>= 2.6.0, < 2.6.32.6.3pip install --upgrade "tensorflow==2.6.3" -
>= 2.7.0, < 2.7.12.7.1pip install --upgrade "tensorflow==2.7.1"
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, users can manually ensure that their applications do not rely on tempfile.mktemp for creating temporary files. Instead, they should use tempfile.mkstemp or tempfile.mkdtemp directly to avoid the vulnerabilities associated with mktemp.
Conclusion
The CVE-2022-23563 vulnerability in TensorFlow poses significant security risks due to the insecure handling of temporary files. It is crucial for users to update to the patched versions to mitigate these risks and ensure the security of their applications.
See every vulnerability recorded for tensorflow →
FAQ
CVE-2022-23563 is a vulnerability in TensorFlow that involves the insecure creation of temporary files, which can lead to security risks.
If your application uses TensorFlow versions affected by this vulnerability, it may be susceptible to unauthorized file access or manipulation.
TensorFlow versions prior to 2.5.3, 2.6.3, 2.7.1, and 2.8.0 are affected by this vulnerability.
You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected without needing to sign up.
If you cannot update TensorFlow right away, consider using the workaround of avoiding tempfile.mktemp and using safer alternatives like tempfile.mkstemp or tempfile.mkdtemp.
References
Related vulnerabilities
Recent vulnerabilities recorded for tensorflow.