CVE-2023-6597 Path traversal in CPython
Attackers can modify permissions of files referenced by symlinks via TemporaryDirectory cleanup, potentially leading to privilege escalation.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2023-6597?
CVE-2023-6597 is a high-severity path traversal vulnerability in CPython, published on 19 Mar 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Official 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.
Which versions are affected by CVE-2023-6597?
3 open source packages ship an affected version, including libpython, python and python-min.
| Package | Affected | Fixed in |
|---|---|---|
libpython Bitnami | All versions | 3.8.19, 3.9.19, 3.10.14, 3.11.8, 3.12.1 |
python Bitnami | All versions | 3.8.19, 3.9.19, 3.10.14, 3.11.8, 3.12.1 |
python-min Bitnami | All versions | 3.8.19, 3.9.19, 3.10.14, 3.11.8, 3.12.1 |
Linux distribution packages (37)
python3.11 AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-debug AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-devel AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-idle AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-libs AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-test AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11-tkinter AlmaLinux:9 | All versions | 3.11.7-1.el9_4.1 |
python3.11 Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-debuginfo Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-debugsource Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-devel Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-libs Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-tkinter Red Hat:enterprise_linux:9::appstream | All versions | 0:3.11.7-1.el9_4.1 |
python3.11 Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-debug Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-debuginfo Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-debugsource Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-idle Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-test Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
python3.11-tkinter Red Hat:enterprise_linux:9::crb | All versions | 0:3.11.7-1.el9_4.1 |
platform-python Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
platform-python-debug Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
platform-python-devel Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
python3-debuginfo Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
python3-debugsource Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
python3-idle Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
python3-test Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
python3-tkinter Red Hat:rhel_aus:8.2::appstream | All versions | 0:3.6.8-24.el8_2.3 |
platform-python Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
python3 Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
python3-debuginfo Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
python3-debugsource Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
python3-libs Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
python3-test Red Hat:rhel_aus:8.2::baseos | All versions | 0:3.6.8-24.el8_2.3 |
platform-python Red Hat:rhel_aus:8.4::appstream | All versions | 0:3.6.8-39.el8_4.5 |
platform-python-debug Red Hat:rhel_aus:8.4::appstream | All versions | 0:3.6.8-39.el8_4.5 |
platform-python-devel Red Hat:rhel_aus:8.4::appstream | All versions | 0:3.6.8-39.el8_4.5 |
How do I fix CVE-2023-6597?
Upgrade libpython to a fixed version for your release line: 3.8.19, 3.9.19, 3.10.14 or 3.11.8.
Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.
Is CVE-2023-6597 being exploited?
There is no known exploitation of CVE-2023-6597 in the wild and no public exploit code.
Sources
Also known as ALPINE-CVE-2023-6597, ALSA-2024:4077, AZL-35926, AZL-35949, BELL-CVE-2023-6597, BIT-libpython-2023-6597 and 26 more.