The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2023-6597

CVE-2023-6597: CPython Privilege Escalation Vulnerability

CVE-2023-6597 is a privilege escalation flaw in CPython's tempfile.TemporaryDirectory class that allows symlink attacks during cleanup. This post covers the technical details, affected versions, and mitigation.

Published: February 11, 2026

CVE-2023-6597 Overview

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, allowing users who can run privileged programs to potentially modify permissions of files referenced by symlinks in some circumstances.

This symlink attack vulnerability represents a significant security concern for Python applications that utilize temporary directories in privileged contexts, as it can lead to unauthorized permission modifications on arbitrary files.

Critical Impact

Users running privileged programs can potentially modify permissions of arbitrary files through symlink manipulation during temporary directory cleanup operations.

Affected Products

  • CPython 3.12.1 and prior
  • CPython 3.11.7 and prior
  • CPython 3.10.13 and prior
  • CPython 3.9.18 and prior
  • CPython 3.8.18 and prior

Discovery Timeline

  • 2024-03-19 - CVE CVE-2023-6597 published to NVD
  • 2025-11-03 - Last updated in NVD database

Technical Details for CVE-2023-6597

Vulnerability Analysis

The vulnerability exists within the tempfile.TemporaryDirectory class in CPython's standard library. When a temporary directory is cleaned up and encounters permission-related errors, the cleanup routine would follow symbolic links rather than operating on the symlink itself. This behavior creates an opportunity for privilege escalation through symlink manipulation.

The flaw is particularly dangerous in scenarios where Python applications run with elevated privileges and use temporary directories. An attacker with the ability to create symlinks within the temporary directory structure can redirect permission modifications to target arbitrary files on the filesystem.

The local attack vector requires the attacker to have the ability to place symlinks in locations accessible to the privileged Python process. While the attack complexity is high due to the specific timing and conditions required, successful exploitation can lead to high impact on both confidentiality and integrity through unauthorized file permission changes.

Root Cause

The root cause of this vulnerability is improper handling of symbolic links during the cleanup phase of tempfile.TemporaryDirectory. The original implementation used os.chmod() and os.chflags() functions without the follow_symlinks=False parameter, causing the functions to follow symlinks and modify permissions on the target files rather than the symlinks themselves.

When the cleanup process encounters permission errors and attempts to reset permissions to allow deletion, it inadvertently follows any symlinks present, potentially modifying permissions on files outside the temporary directory structure.

Attack Vector

The attack scenario involves the following steps:

  1. A privileged Python application creates a TemporaryDirectory instance
  2. An attacker with access to the temporary directory creates a symbolic link pointing to a target file (e.g., /etc/passwd or other sensitive system files)
  3. When the TemporaryDirectory is cleaned up and encounters a permission error, the cleanup routine attempts to reset permissions
  4. Due to the symlink following behavior, the permission reset operation affects the target file instead of the symlink

The fix introduces a _dont_follow_symlinks() helper function that ensures permission-modifying operations do not follow symbolic links:

python
def _dont_follow_symlinks(func, path, *args):
    # Pass follow_symlinks=False, unless not supported on this platform.
    if func in _os.supports_follow_symlinks:
        func(path, *args, follow_symlinks=False)
    elif _os.name == 'nt' or not _os.path.islink(path):
        func(path, *args)

def _resetperms(path):
    try:
        chflags = _os.chflags
    except AttributeError:
        pass
    else:
        _dont_follow_symlinks(chflags, path, 0)
    _dont_follow_symlinks(_os.chmod, path, 0o700)

Source: GitHub CPython Commit Update 02a9259

Detection Methods for CVE-2023-6597

Indicators of Compromise

  • Unexpected permission changes on sensitive system files following Python script execution
  • Presence of symbolic links within temporary directories pointing to critical system files
  • Audit logs showing permission modifications on files outside expected application scope
  • Anomalous activity involving privileged Python processes and temporary directory operations

Detection Strategies

  • Monitor for symlink creation within standard temporary directory paths (/tmp, /var/tmp, application-specific temp directories)
  • Implement file integrity monitoring on critical system files to detect unauthorized permission changes
  • Audit Python process activity, particularly those running with elevated privileges that utilize tempfile.TemporaryDirectory
  • Deploy SentinelOne agents to detect and alert on suspicious file permission modifications following symlink traversal patterns

Monitoring Recommendations

  • Configure security monitoring to track chmod and chflags system calls from Python processes in privileged contexts
  • Enable audit logging for all file operations within temporary directories on systems running critical Python applications
  • Implement real-time alerting for permission changes on files in /etc, /usr, and other system-critical directories
  • Use SentinelOne's behavioral AI to identify privilege escalation attempts through symlink manipulation

How to Mitigate CVE-2023-6597

Immediate Actions Required

  • Update CPython to the latest patched version for your branch (3.12.2+, 3.11.8+, 3.10.14+, 3.9.19+, or 3.8.19+)
  • Review applications using tempfile.TemporaryDirectory in privileged contexts and assess exposure
  • Implement filesystem permissions to restrict symlink creation in temporary directories where possible
  • Consider using dedicated temporary directories with restricted permissions for privileged applications

Patch Information

The Python development team has released security patches across all supported Python branches. The fix introduces the _dont_follow_symlinks() helper function in Lib/tempfile.py that ensures permission-related operations do not follow symbolic links. Multiple commits address this issue across different Python versions:

  • GitHub CPython Commit 02a9259 - Python 3.8 branch
  • GitHub CPython Commit 5585334 - Python 3.11 branch
  • GitHub CPython Commit 6ceb8ae - Python 3.12 branch

For additional information, see the GitHub CPython Issue #91133 and Python Security Announcement Thread.

Linux distribution users should apply updates from their distribution vendors. See Debian LTS Announcement March 2024 and Fedora Package Announcement March 2024 for distribution-specific guidance.

Workarounds

  • Avoid running Python applications that use tempfile.TemporaryDirectory with elevated privileges when possible
  • Use tempfile.mkdtemp() with manual cleanup that explicitly checks for and avoids following symlinks
  • Implement a wrapper around TemporaryDirectory that verifies no symlinks exist before cleanup
  • Mount temporary directories with the nosymfollow option where supported by the filesystem
bash
# Configure temporary directory with restricted permissions
mkdir -p /secure_tmp
chmod 1733 /secure_tmp
# Set TMPDIR environment variable for Python applications
export TMPDIR=/secure_tmp
# Alternatively, mount tmpfs with restricted options
mount -t tmpfs -o mode=1733,nosuid,nodev,noexec tmpfs /secure_tmp

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypePrivilege Escalation

  • Vendor/TechPython

  • SeverityHIGH

  • CVSS Score7.8

  • EPSS Probability0.07%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:N
  • Impact Assessment
  • ConfidentialityHigh
  • IntegrityNone
  • AvailabilityNone
  • Technical References
  • Openwall OSS-Security Discussion

  • GitHub CPython Commit Update 02a9259

  • GitHub CPython Commit Update 5585334

  • GitHub CPython Commit Update 6ceb8ae

  • GitHub CPython Commit Update 81c16cd

  • GitHub CPython Commit Update 8eaeefe

  • GitHub CPython Commit Update d54e22a

  • GitHub CPython Issue #91133

  • Debian LTS Announcement March 2024

  • Fedora Package Announcement March 2024

  • Fedora Package Announcement March 2024

  • Python Security Announcement Thread

  • Debian LTS Announcement November 2024

  • Debian LTS Announcement December 2024
  • Related CVEs
  • CVE-2022-42919: Python Privilege Escalation Vulnerability

  • CVE-2023-6507: Python Privilege Escalation Vulnerability

  • CVE-2025-13462: Python tarfile Module Parsing Vulnerability

  • CVE-2026-2297: CPython Information Disclosure Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English