CVE-2025-59042

Source
https://nvd.nist.gov/vuln/detail/CVE-2025-59042
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-59042.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-59042
Aliases
Published
2025-09-09T23:15:37Z
Modified
2025-09-19T15:30:18.959128Z
Summary
[none]
Details

PyInstaller bundles a Python application and all its dependencies into a single package. Due to a special entry being appended to sys.path during the bootstrap process of a PyInstaller-frozen application, and due to the bootstrap script attempting to load an optional module for bytecode decryption while this entry is still present in sys.path, an application built with PyInstaller < 6.0.0 may be tricked by an unprivileged attacker into executing arbitrary python code when all of the following conditions are met. First, the application is built with PyInstaller < 6.0.0; both onedir and onefile mode are affected. Second, the optional bytecode encryption code feature was not enabled during the application build. Third, the attacker can create files/directories in the same directory where the executable is located. Fourth, the filesystem supports creation of files/directories that contain ? in their name (i.e., non-Windows systems). Fifth, the attacker is able to determine the offset at which the PYZ archive is embedded in the executable. The attacker can create a directory (or a zip archive) next to the executable, with the name that matches the format used by PyInstaller's bootloader to transmit information about the location of PYZ archive to the bootstrap script. If this directory (or zip archive) contains a python module whose name matches the name used by the optional bytecode encryption feature, this module will be loaded and executed by the bootstrap script (in the absence of the real, built-in module that is available when the bytecode-encryption feature is enabled). This results in arbitrary code execution that requires no modification of the executable itself. If the executable is running with elevated privileges (for example, due to having the setuid bit set), the code in the injected module is also executed with the said elevated privileges, resulting in a local privilege escalation. PyInstaller 6.0.0 (f5adf291c8b832d5aff7632844f7e3ddf7ad4923) removed support for bytecode encryption; this effectively removes the described attack vector, due to the bootstrap script not attempting to load the optional module for bytecode-decryption anymore. PyInstaller 6.10.0 (cfd60b510f95f92cb81fc42735c399bb781a4739) reworked the bootstrap process to avoid (ab)using sys.path for transmitting location of the PYZ archive, which further eliminates the possibility of described injection procedure. If upgrading PyInstaller is not feasible, this issue can be worked around by ensuring proper permissions on directories containing security-sensitive executables (i.e., executables with setuid bit set) should mitigate the issue.

References

Affected packages

Git / github.com/pyinstaller/pyinstaller

Affected ranges

Type
GIT
Repo
https://github.com/pyinstaller/pyinstaller
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Fixed

Affected versions

3.*

3.0
3.0.dev2
3.0.dev6
3.0.dev7
3.0.dev8

v1.*

v1.0
v1.0-rc1
v1.1
v1.1-rc1
v1.1-rc2
v1.1-rc3
v1.2
v1.3
v1.4
v1.4-rc1
v1.5
v1.5-rc1
v1.5-rc2
v1.5.1
v1.5.1-rc1

v2.*

v2.0
v2.1

v3.*

v3.1
v3.1.1
v3.2
v3.2.1
v3.3
v3.3.1
v3.4
v3.5
v3.6

v4.*

v4.0
v4.1
v4.2
v4.3
v4.4
v4.5

v5.*

v5.0
v5.0.1
v5.1
v5.10.0
v5.10.1
v5.11.0
v5.12.0
v5.13.0
v5.2
v5.3
v5.4
v5.4.1
v5.5
v5.6.1
v5.6.2
v5.7.0
v5.8.0
v5.9.0