CVE-2024-4030 tempfile.mkdtemp() may be readable and writeable by all users on Windows

High 7.1 Published Updated

On Windows, tempfile.mkdtemp() may create directories with overly permissive access rights, allowing other users to read or modify temporary files.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2024-4030?

CVE-2024-4030 is a high-severity vulnerability in CPython, published on 7 May 2024. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

On Windows a directory returned by tempfile.mkdtemp() would not always have permissions set to restrict reading and writing to the temporary directory by other users, instead usually inheriting the correct permissions from the default location. Alternate configurations or users without a profile directory may not have the intended permissions.

If you’re not using Windows or haven’t changed the temporary directory location then you aren’t affected by this vulnerability. On other platforms the returned directory is consistently readable and writable only by the current user.

This issue was caused by Python not supporting Unix permissions on Windows. The fix adds support for Unix “700” for the mkdir function on Windows which is used by mkdtemp() to ensure the newly created directory has the proper permissions.

Weakness: CWE-276

Which versions are affected by CVE-2024-4030?

1 open source package ship an affected version, including python.

PackageAffectedFixed in
python BitnamiAll versions3.12.4
Linux distribution packages (1)
python39 openSUSE:TumbleweedAll versions3.9.20-1.1

How do I fix CVE-2024-4030?

Upgrade python to 3.12.4 or later.

Is CVE-2024-4030 being exploited?

There is no known exploitation of CVE-2024-4030 in the wild and no public exploit code.

Sources

Also known as BIT-python-2024-4030, GHSA-2w87-6hh6-mqrj, PSF-2024-3, openSUSE-SU-2024:14331-1.

Is CVE-2024-4030 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free