Cloudanix VulnDB

CVE-2023-6597

High · 7.8

CVSS

7.8

EPSS

0.3%

Published

Mar 19, 2024

CISA due date

—

Cloudanix analysis

Schedule a fix SSVC: Track

A Python bug in handling temporary folders could let someone who runs certain programs change permissions on other files on the same system.

Exploitation
Local Privilege
Attacker needs
Local User
Complexity
High
Impact
Privilege Gain
Component
Library
Class
Path Traversal
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

TemporaryDirectory dereferences symlinks when handling permission-related errors during cleanup, enabling modification of permissions on arbitrary files referenced by those symlinks.

Why it matters to the business

Attackers able to influence temporary directory operations on systems running affected Python versions may alter file permissions, potentially enabling unauthorized access or privilege changes; low urgency due to absence from KEV, stable low EPSS, and no known ransomware use, but widespread Python deployment increases exposure risk.

How an attack unfolds

An attacker with the ability to run privileged programs creates symlinks inside a TemporaryDirectory pointing to target files; during cleanup triggered by a permissions error the class follows the symlinks and modifies permissions on the linked targets.

How to fix it

Upgrade Python to a version containing commit 02a9259c717738dfe6b463c44d7e17f2b6d2cb3a or later patched releases (3.12.2+, 3.11.8+, 3.10.14+, 3.9.19+, 3.8.19+); for AlmaLinux 8 packages update json-c, json-c-devel and json-c-doc to 0.13.1-3.el8.

How to confirm the fix worked

Confirm Python version is newer than the listed vulnerable releases and verify that TemporaryDirectory no longer follows symlinks during permission-error cleanup by running targeted unit tests on symlink handling.

Typical attack path

  1. Identify or create a scenario where TemporaryDirectory is used and a permissions error can be induced during cleanup
  2. Place symlinks inside the temporary directory that point to attacker-chosen target files
  3. Trigger the cleanup path that dereferences symlinks on error
  4. Observe or leverage the resulting permission changes on the target files

How to detect it

Review system logs for unexpected permission changes on files referenced by temporary directories; examine Python application logs for TemporaryDirectory usage around the time of permission modifications.

What your security team should do

  • Apply the listed fixed Python versions or commit across all environments within standard patch windows
  • Audit code that uses tempfile.TemporaryDirectory for symlink assumptions
  • Monitor EPSS and KEV status for any future increase in exploit activity

The record

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.

Affected packages

Ecosystem Package Introduced Fixed
AlmaLinux:8 platform-python 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 platform-python-debug 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 platform-python-devel 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 python3-idle 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 python3-libs 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 python3-test 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 python3-tkinter 0 3.6.8-62.el8_10.alma.1
AlmaLinux:8 python3.11 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-debug 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-devel 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-idle 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-libs 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-rpm-macros 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-test 0 3.11.9-1.el8_10
AlmaLinux:8 python3.11-tkinter 0 3.11.9-1.el8_10
AlmaLinux:8 python39 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-Cython 0 0.29.21-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-Cython 0 0.29.21-5.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-PyMySQL 0 0.10.1-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-attrs 0 20.3.0-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cffi 0 1.14.3-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cffi 0 1.14.3-2.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-chardet 0 3.0.4-19.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-cryptography 0 3.3.1-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-debug 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-devel 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-idle 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-idna 0 2.10-4.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-iniconfig 0 1.1.1-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-libs 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-lxml 0 4.6.5-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-lxml 0 4.6.5-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-mod_wsgi 0 4.7.1-7.module_el8.9.0+3634+fb2a896c
AlmaLinux:8 python39-more-itertools 0 8.5.0-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy 0 1.19.4-3.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-numpy-doc 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy-f2py 0 1.19.4-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-numpy-f2py 0 1.19.4-3.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-packaging 0 20.4-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pip 0 20.2.4-9.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-pip-wheel 0 20.2.4-9.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-pluggy 0 0.13.1-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-ply 0 3.11-10.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-psutil 0 5.8.0-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-psutil 0 5.8.0-4.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-psycopg2 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-psycopg2-doc 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-psycopg2-tests 0 2.8.6-3.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-py 0 1.10.0-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11 0 2.7.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11 0 2.7.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-pybind11-devel 0 2.7.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pybind11-devel 0 2.7.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-pycparser 0 2.20-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyparsing 0 2.4.7-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pysocks 0 1.7.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pytest 0 6.0.2-2.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyyaml 0 5.4.1-1.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-pyyaml 0 5.4.1-1.module_el8.6.0+3248+c431e88c
AlmaLinux:8 python39-requests 0 2.25.0-3.module_el8.9.0+3634+fb2a896c
AlmaLinux:8 python39-rpm-macros 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-scipy 0 1.5.4-5.module_el8.9.0+3634+fb2a896c
AlmaLinux:8 python39-setuptools 0 50.3.2-5.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-setuptools-wheel 0 50.3.2-5.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-six 0 1.15.0-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-test 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-tkinter 0 3.9.19-1.module_el8.10.0+3849+a48d89aa
AlmaLinux:8 python39-toml 0 0.10.1-5.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-urllib3 0 1.25.10-5.module_el8.10.0+3765+2f9a457d
AlmaLinux:8 python39-wcwidth 0 0.2.5-3.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-wheel 0 1:0.35.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:8 python39-wheel-wheel 0 1:0.35.1-4.module_el8.6.0+2780+a40f65e1
AlmaLinux:9 python-unversioned-command 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-debug 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-devel 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-idle 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-libs 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-test 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3-tkinter 0 3.9.18-3.el9_4.1
AlmaLinux:9 python3.11 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-debug 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-devel 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-idle 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-libs 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-test 0 3.11.7-1.el9_4.1
AlmaLinux:9 python3.11-tkinter 0 3.11.7-1.el9_4.1
Alpine:v3.16 python3 0 3.10.14-r0
Alpine:v3.17 python3 0 3.10.14-r0
Bitnami libpython 0 3.8.19
Bitnami python 0 3.8.19
Bitnami python 3.12.0 3.12.3
Bitnami python-min 0 3.8.19
Chainguard aws-cli-v2 0 2.15.35-r0
Chainguard python-3.10 0 3.10.14-r0
Chainguard python-3.10-base 0 3.10.14-r0
Chainguard python-3.10-base-dev 0 3.10.14-r0
Chainguard python-3.10-dev 0 3.10.14-r0
Chainguard python-3.10-doc 0 3.10.14-r0
Chainguard python-3.11 0 3.11.8-r0
Chainguard python-3.11-base 0 3.11.8-r0
Chainguard python-3.11-base-dev 0 3.11.8-r0
Chainguard python-3.11-dev 0 3.11.8-r0
Chainguard python-3.11-doc 0 3.11.8-r0
Chainguard python-3.12 0 3.12.2-r0
Chainguard python-3.12-base 0 3.12.2-r0
Chainguard python-3.12-base-dev 0 3.12.2-r0
Chainguard python-3.12-dev 0 3.12.2-r0
Chainguard python-3.12-doc 0 3.12.2-r0
Chainguard python-3.12-privileged-netbindservice 0 3.12.2-r0
Chainguard python-3.12-tk 0 3.12.2-r0
Chainguard python-3.8 0 3.8.19-r0
Chainguard python-3.8-base 0 3.8.19-r0
Chainguard python-3.8-base-dev 0 3.8.19-r0
Chainguard python-3.8-default 0 3.8.19-r0
Chainguard python-3.8-dev 0 3.8.19-r0
Chainguard python-3.8-doc 0 3.8.19-r0
Chainguard python-3.9 0 3.9.19-r0
Chainguard python-3.9-base 0 3.9.19-r0
Chainguard python-3.9-base-dev 0 3.9.19-r0
Chainguard python-3.9-default 0 3.9.19-r0
Chainguard python-3.9-dev 0 3.9.19-r0
Chainguard python-3.9-doc 0 3.9.19-r0
Debian:10 python3.7 0 3.7.3-2+deb10u7
Debian:11 pypy3 0 No fix
Debian:11 pypy3 0 7.3.5+dfsg-2+deb11u3
Debian:11 python3.9 0 No fix
Debian:11 python3.9 0 3.9.2-1+deb11u2
Debian:12 pypy3 0 7.3.11+dfsg-2+deb12u2
Debian:12 python3.11 0 3.11.2-6+deb12u2
Debian:13 pypy3 0 7.3.13+dfsg-1
Debian:13 python3.12 0 3.12.1-1
Mageia:9 python 0 2.7.18-15.2.mga9
Mageia:9 python3 0 3.10.11-1.2.mga9
Red Hat:enterprise_linux:8::appstream PyYAML 0 0:5.4.1-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream PyYAML-debugsource 0 0:5.4.1-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream mod_wsgi 0 0:4.7.1-7.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream numpy 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream numpy-debugsource 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream platform-python 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream platform-python-debug 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream platform-python-devel 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python-PyMySQL 0 0:0.10.1-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-cffi 0 0:1.14.3-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-cffi-debugsource 0 0:1.14.3-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-chardet 0 0:3.0.4-19.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-cryptography 0 0:3.3.1-3.module+el8.10.0+21271+eccd1d86
Red Hat:enterprise_linux:8::appstream python-cryptography-debugsource 0 0:3.3.1-3.module+el8.10.0+21271+eccd1d86
Red Hat:enterprise_linux:8::appstream python-idna 0 0:2.10-4.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python-lxml 0 0:4.6.5-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-lxml-debugsource 0 0:4.6.5-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-ply 0 0:3.11-10.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-psutil 0 0:5.8.0-4.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-psutil-debugsource 0 0:5.8.0-4.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-psycopg2 0 0:2.8.6-3.module+el8.10.0+21142+453d2b75
Red Hat:enterprise_linux:8::appstream python-psycopg2-debugsource 0 0:2.8.6-3.module+el8.10.0+21142+453d2b75
Red Hat:enterprise_linux:8::appstream python-pycparser 0 0:2.20-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-pysocks 0 0:1.7.1-4.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-requests 0 0:2.25.0-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-toml 0 0:0.10.1-5.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python-urllib3 0 0:1.25.10-5.module+el8.10.0+20443+f0a692fe
Red Hat:enterprise_linux:8::appstream python-wheel 0 1:0.35.1-4.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python3 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-debuginfo 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-debugsource 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-idle 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-libs 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-test 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3-tkinter 0 0:3.6.8-62.el8_10
Red Hat:enterprise_linux:8::appstream python3.11 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debug 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debuginfo 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-debugsource 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-devel 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-idle 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-libs 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-rpm-macros 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-test 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python3.11-tkinter 0 0:3.11.9-1.el8_10
Red Hat:enterprise_linux:8::appstream python39 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-PyMySQL 0 0:0.10.1-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-cffi 0 0:1.14.3-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-cffi-debuginfo 0 0:1.14.3-2.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-chardet 0 0:3.0.4-19.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-cryptography 0 0:3.3.1-3.module+el8.10.0+21271+eccd1d86
Red Hat:enterprise_linux:8::appstream python39-cryptography-debuginfo 0 0:3.3.1-3.module+el8.10.0+21271+eccd1d86
Red Hat:enterprise_linux:8::appstream python39-debuginfo 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-debugsource 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-devel 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-idle 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-idna 0 0:2.10-4.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-libs 0 0:3.9.19-1.module+el8.10.0+21815+bb024982
Red Hat:enterprise_linux:8::appstream python39-lxml 0 0:4.6.5-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-lxml-debuginfo 0 0:4.6.5-1.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-mod_wsgi 0 0:4.7.1-7.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-numpy 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-numpy-debuginfo 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-numpy-doc 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d
Red Hat:enterprise_linux:8::appstream python39-numpy-f2py 0 0:1.19.4-3.module+el8.9.0+19644+d68f775d

Related vulnerabilities