Vulnerability in CPython TemporaryDirectory Class
Summary
CVE-2023-6597: An issue was found in the CPython tempfile.TemporaryDirectory class affecting versions 3.12.1, 3.11.7, 3.10.13, 3.9.18, and 3.8.18 and prior. Affects python3 across 7 version ranges.
< 02a9259c717738dfe6b463c44d7e17f2b6d2cb3a
< 3.10.14-r0
< 6ceb8aeda504b079fef7a57b8d81472f15cdd9a5
< 8eaeefe49d179ca4908d052745e3bb8b6f238f82
< 81c16cd94ec38d61aa478b9a452436dc3b1b524d
< 5585334d772b253a01a6730e8202ffb1607c3d25
< d54e22a669ae6e987199bb5d2c69bb5a46b0083b
Fixed in 3.10.14-r0. How to fix ↓
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
CPython is an implementation of the Python programming language. It provides a comprehensive standard library, including the tempfile module, which offers functions and classes for working with temporary files and directories. One of these classes is TemporaryDirectory, which creates a temporary directory that is automatically deleted when it is no longer needed. However, a vulnerability has been discovered in the TemporaryDirectory class that affects versions 3.12.2, 3.11.8, 3.10.13, 3.9.18, and 3.8.18 and prior.
Vulnerability Detail
The vulnerability, identified as CVE-2023-6597, occurs when the TemporaryDirectory class dereferences symlinks during the cleanup process of permissions-related errors. This means that users who can run privileged programs may be able to modify the permissions of files referenced by symlinks under certain circumstances. This could potentially lead to unauthorized access or manipulation of sensitive files.
How To Fix
Minimum fixed version
3.10.14-r0
This is the first release that contains the fix.
sudo apk add --upgrade python3
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, users can manually check and modify the permissions of files referenced by symlinks to prevent unauthorized access. However, this is not a comprehensive solution and should only be used until the package update can be applied.
Conclusion
In conclusion, the CPython TemporaryDirectory class is vulnerable to symlink dereferencing, which could allow unauthorized access or manipulation of files. It is crucial to update to version 3.10.14 or later of the python3 package to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for python3 →
FAQ
The vulnerability allows users with the ability to run privileged programs to potentially modify the permissions of files referenced by symlinks. This could lead to unauthorized access or manipulation of sensitive files.
Versions 3.12.2, 3.11.8, 3.10.13, 3.9.18, and 3.8.18 and prior are affected by this vulnerability.
You can use the Vulert Playground at Vulert Scanner to check if your Python installation is affected by this vulnerability. Simply upload your manifest file, such as package-lock.json, and the tool will analyze it for any open-source vulnerabilities.
Yes, a fix is available in version 3.10.14 or later of the python3 package. It is recommended to update your Python installation to the latest fixed version.
You can find more information about this vulnerability, including the technical details and the CVE identifier, in the CVE-2023-6597 JSON report available at https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-6597.json.
References
Related vulnerabilities
Recent vulnerabilities recorded for python3.