CVE-2023-6597: Vulnerability in Python Software Foundation CPython
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. The tempfile.TemporaryDirectory class would dereference symlinks during cleanup of permissions-related errors. This means users which can run privileged programs are potentially able to modify permissions of files referenced by symlinks in some circumstances.
AI Analysis
Technical Summary
CVE-2023-6597 is a vulnerability discovered in the CPython implementation of the tempfile.TemporaryDirectory class, impacting versions 3.8.18, 3.9.18, 3.10.13, 3.11.7, and 3.12.1. The flaw occurs during the cleanup phase of TemporaryDirectory when permissions-related errors arise. Specifically, the class dereferences symbolic links (symlinks) instead of handling them safely, which can lead to unintended modification of file permissions on the target files that symlinks point to. This behavior can be exploited by users who have the capability to run privileged programs locally, enabling them to manipulate permissions of arbitrary files referenced by symlinks. Such manipulation could facilitate privilege escalation or unauthorized access to sensitive files, compromising confidentiality and integrity. The vulnerability does not require user interaction but does require local access and the ability to execute privileged code. The CVSS 3.1 base score is 7.8, reflecting high severity with a vector indicating local attack vector, high attack complexity, no privileges required, no user interaction, and scope change with high confidentiality and integrity impact but no availability impact. No public exploits have been reported yet, but the vulnerability poses a significant risk in multi-user or shared environments where symlinks and privileged programs coexist. The Python Software Foundation has published the vulnerability details, but patch links were not provided at the time of this report.
Potential Impact
For European organizations, the vulnerability presents a risk primarily in environments where Python is used extensively for automation, scripting, or application development, especially in multi-user or shared systems such as servers or development platforms. Attackers with local access and the ability to run privileged programs could exploit this flaw to alter file permissions on critical files, potentially leading to privilege escalation or unauthorized data access. This could compromise sensitive information, disrupt application integrity, and undermine trust in automated processes. Sectors such as finance, healthcare, government, and critical infrastructure that rely on Python-based tools or services are particularly vulnerable. The impact is heightened in organizations that allow users to create symlinks or run privileged scripts without strict controls. Although no known exploits exist yet, the vulnerability’s presence in widely used Python versions means that unpatched systems remain at risk of targeted attacks or insider threats.
Mitigation Recommendations
1. Monitor for and apply official patches or updates from the Python Software Foundation as soon as they become available to address CVE-2023-6597. 2. Until patches are applied, restrict the ability of untrusted users to execute privileged programs or scripts that utilize tempfile.TemporaryDirectory, especially in environments where symlinks can be created. 3. Implement strict filesystem permissions and policies to limit symlink creation and usage by non-administrative users. 4. Audit existing codebases and scripts for usage of tempfile.TemporaryDirectory in privileged contexts and refactor or add safeguards to prevent symlink dereferencing during cleanup. 5. Employ runtime monitoring to detect unusual permission changes or symlink manipulations on critical files. 6. Educate developers and system administrators about the risks of symlink dereferencing in privileged operations and encourage secure coding practices. 7. Use containerization or sandboxing to isolate processes that handle temporary directories to minimize potential damage from exploitation.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Italy, Spain
CVE-2023-6597: Vulnerability in Python Software Foundation CPython
Description
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. The tempfile.TemporaryDirectory class would dereference symlinks during cleanup of permissions-related errors. This means users which can run privileged programs are potentially able to modify permissions of files referenced by symlinks in some circumstances.
AI-Powered Analysis
Technical Analysis
CVE-2023-6597 is a vulnerability discovered in the CPython implementation of the tempfile.TemporaryDirectory class, impacting versions 3.8.18, 3.9.18, 3.10.13, 3.11.7, and 3.12.1. The flaw occurs during the cleanup phase of TemporaryDirectory when permissions-related errors arise. Specifically, the class dereferences symbolic links (symlinks) instead of handling them safely, which can lead to unintended modification of file permissions on the target files that symlinks point to. This behavior can be exploited by users who have the capability to run privileged programs locally, enabling them to manipulate permissions of arbitrary files referenced by symlinks. Such manipulation could facilitate privilege escalation or unauthorized access to sensitive files, compromising confidentiality and integrity. The vulnerability does not require user interaction but does require local access and the ability to execute privileged code. The CVSS 3.1 base score is 7.8, reflecting high severity with a vector indicating local attack vector, high attack complexity, no privileges required, no user interaction, and scope change with high confidentiality and integrity impact but no availability impact. No public exploits have been reported yet, but the vulnerability poses a significant risk in multi-user or shared environments where symlinks and privileged programs coexist. The Python Software Foundation has published the vulnerability details, but patch links were not provided at the time of this report.
Potential Impact
For European organizations, the vulnerability presents a risk primarily in environments where Python is used extensively for automation, scripting, or application development, especially in multi-user or shared systems such as servers or development platforms. Attackers with local access and the ability to run privileged programs could exploit this flaw to alter file permissions on critical files, potentially leading to privilege escalation or unauthorized data access. This could compromise sensitive information, disrupt application integrity, and undermine trust in automated processes. Sectors such as finance, healthcare, government, and critical infrastructure that rely on Python-based tools or services are particularly vulnerable. The impact is heightened in organizations that allow users to create symlinks or run privileged scripts without strict controls. Although no known exploits exist yet, the vulnerability’s presence in widely used Python versions means that unpatched systems remain at risk of targeted attacks or insider threats.
Mitigation Recommendations
1. Monitor for and apply official patches or updates from the Python Software Foundation as soon as they become available to address CVE-2023-6597. 2. Until patches are applied, restrict the ability of untrusted users to execute privileged programs or scripts that utilize tempfile.TemporaryDirectory, especially in environments where symlinks can be created. 3. Implement strict filesystem permissions and policies to limit symlink creation and usage by non-administrative users. 4. Audit existing codebases and scripts for usage of tempfile.TemporaryDirectory in privileged contexts and refactor or add safeguards to prevent symlink dereferencing during cleanup. 5. Employ runtime monitoring to detect unusual permission changes or symlink manipulations on critical files. 6. Educate developers and system administrators about the risks of symlink dereferencing in privileged operations and encourage secure coding practices. 7. Use containerization or sandboxing to isolate processes that handle temporary directories to minimize potential damage from exploitation.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- PSF
- Date Reserved
- 2023-12-07T20:59:23.246Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 69092613fe7723195e0b3005
Added to database: 11/3/2025, 10:00:51 PM
Last enriched: 11/3/2025, 11:09:32 PM
Last updated: 11/5/2025, 2:19:31 PM
Views: 1
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Related Threats
CVE-2025-12497: CWE-98 Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion') in averta Premium Portfolio Features for Phlox theme
HighCVE-2025-11745: CWE-80 Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) in spacetime Ad Inserter – Ad Manager & AdSense Ads
MediumCVE-2025-58337: CWE-284 Improper Access Control in Apache Software Foundation Apache Doris-MCP-Server
UnknownCVE-2025-12469: CWE-862 Missing Authorization in amans2k FunnelKit Automations – Email Marketing Automation and CRM for WordPress & WooCommerce
MediumCVE-2025-12468: CWE-200 Exposure of Sensitive Information to an Unauthorized Actor in amans2k FunnelKit Automations – Email Marketing Automation and CRM for WordPress & WooCommerce
MediumActions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.