Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. PyInstaller
  4. ›
  5. CVE-2025-59042

CVE-2025-59042: PyInstaller has local privilege escalation vulnerability

September 10, 2025

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:

  1. Application is built with PyInstaller < 6.0.0; both onedir and onefile mode are affected.
  2. Optional bytecode encryption code feature was not enabled during the application build.
  3. The attacker can create files/directories in the same directory where the executable is located.
  4. The filesystem supports creation of files/directories that contain ? in their name (i.e., non-Windows systems).
  5. 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.

References

  • github.com/advisories/GHSA-p2xp-xx3r-mffc
  • github.com/pyinstaller/pyinstaller
  • github.com/pyinstaller/pyinstaller/commit/f5adf291c8b832d5aff7632844f7e3ddf7ad4923
  • github.com/pyinstaller/pyinstaller/security/advisories/GHSA-p2xp-xx3r-mffc
  • nvd.nist.gov/vuln/detail/CVE-2025-59042

Code Behaviors & Features

Detect and mitigate CVE-2025-59042 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 6.0.0

Fixed versions

  • 6.0.0

Solution

Upgrade to version 6.0.0 or above.

Weakness

  • CWE-94: Improper Control of Generation of Code ('Code Injection')

Source file

pypi/PyInstaller/CVE-2025-59042.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 14 Sep 2025 12:19:05 +0000.