← Back to CVE Explorer

CVE-2025-59042

Full vulnerability record from the local CVENow database.

Description

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.

Severity
HIGH
CVSS score
7.0 (v4.0)
Vulnerability status
Deferred
Source identifier
Published
2025-09-09 23:15:37.403000
Last modified
2026-10-23 22:10:00.160000
View original CVE JSON
{
  "id": "CVE-2025-59042",
  "sourceIdentifier": "[email protected]",
  "published": "2025-09-09T23:15:37.403",
  "lastModified": "2026-10-23T22:10:00.160",
  "vulnStatus": "Deferred",
  "cveTags": [],
  "descriptions": [
    {
      "lang": "en",
      "value": "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."
    },
    {
      "lang": "es",
      "value": "PyInstaller empaqueta una aplicación Python y todas sus dependencias en un único paquete. Debido a que se añade una entrada especial a 'sys.path' durante el proceso de arranque de una aplicación congelada con PyInstaller, y debido a que el script de arranque intenta cargar un módulo opcional para el descifrado de bytecode mientras esta entrada todavía está presente en 'sys.path', una aplicación construida con PyInstaller anterior a 6.0.0 puede ser engañada por un atacante no privilegiado para la ejecución de código python arbitrario cuando se cumplen todas las siguientes condiciones. Primero, la aplicación está construida con PyInstaller anterior a 6.0.0; tanto el modo onedir como el onefile están afectados. Segundo, la característica opcional de cifrado de código de bytecode no estaba habilitada durante la construcción de la aplicación. Tercero, el atacante puede crear archivos/directorios en el mismo directorio donde se encuentra el ejecutable. Cuarto, el sistema de archivos soporta la creación de archivos/directorios que contienen '?' en su nombre (es decir, sistemas que no son Windows). Quinto, el atacante es capaz de determinar el desplazamiento en el que el archivo PYZ está incrustado en el ejecutable. El atacante puede crear un directorio (o un archivo zip) junto al ejecutable, con el nombre que coincide con el formato utilizado por el cargador de arranque de PyInstaller para transmitir información sobre la ubicación del archivo PYZ al script de arranque. Si este directorio (o archivo zip) contiene un módulo python cuyo nombre coincide con el nombre utilizado por la característica opcional de cifrado de bytecode, este módulo será cargado y ejecutado por el script de arranque (en ausencia del módulo real, incorporado que está disponible cuando la característica de cifrado de bytecode está habilitada). Esto resulta en ejecución de código arbitrario que no requiere modificación del propio ejecutable. Si el ejecutable se está ejecutando con privilegios elevados (por ejemplo, debido a tener el bit 'setuid' establecido), el código en el módulo inyectado también se ejecuta con dichos privilegios elevados, resultando en una escalada de privilegios local. PyInstaller 6.0.0 (f5adf291c8b832d5aff7632844f7e3ddf7ad4923) eliminó el soporte para el cifrado de bytecode; esto elimina efectivamente el vector de ataque descrito, debido a que el script de arranque ya no intenta cargar el módulo opcional para el descifrado de bytecode. PyInstaller 6.10.0 (cfd60b510f95f92cb81fc42735c399bb781a4739) reelaboró el proceso de arranque para evitar (mal)usar 'sys.path' para transmitir la ubicación del archivo PYZ, lo que elimina aún más la posibilidad del procedimiento de inyección descrito. Si la actualización de PyInstaller no es factible, este problema puede solucionarse asegurando permisos adecuados en los directorios que contienen ejecutables sensibles a la seguridad (es decir, ejecutables con el bit 'setuid' establecido) debería mitigar el problema."
    }
  ],
  "affected": [
    {
      "source": "[email protected]",
      "affectedData": [
        {
          "vendor": "pyinstaller",
          "product": "pyinstaller",
          "versions": [
            {
              "version": "< 6.0.0",
              "status": "affected"
            }
          ]
        }
      ]
    }
  ],
  "metrics": {
    "cvssMetricV40": [
      {
        "source": "[email protected]",
        "type": "Secondary",
        "cvssData": {
          "version": "4.0",
          "vectorString": "CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
          "baseScore": 7.0,
          "baseSeverity": "HIGH",
          "attackVector": "LOCAL",
          "attackComplexity": "LOW",
          "attackRequirements": "NONE",
          "privilegesRequired": "LOW",
          "userInteraction": "PASSIVE",
          "vulnConfidentialityImpact": "HIGH",
          "vulnIntegrityImpact": "HIGH",
          "vulnAvailabilityImpact": "HIGH",
          "subConfidentialityImpact": "NONE",
          "subIntegrityImpact": "NONE",
          "subAvailabilityImpact": "NONE",
          "exploitMaturity": "NOT_DEFINED",
          "confidentialityRequirement": "NOT_DEFINED",
          "integrityRequirement": "NOT_DEFINED",
          "availabilityRequirement": "NOT_DEFINED",
          "modifiedAttackVector": "NOT_DEFINED",
          "modifiedAttackComplexity": "NOT_DEFINED",
          "modifiedAttackRequirements": "NOT_DEFINED",
          "modifiedPrivilegesRequired": "NOT_DEFINED",
          "modifiedUserInteraction": "NOT_DEFINED",
          "modifiedVulnConfidentialityImpact": "NOT_DEFINED",
          "modifiedVulnIntegrityImpact": "NOT_DEFINED",
          "modifiedVulnAvailabilityImpact": "NOT_DEFINED",
          "modifiedSubConfidentialityImpact": "NOT_DEFINED",
          "modifiedSubIntegrityImpact": "NOT_DEFINED",
          "modifiedSubAvailabilityImpact": "NOT_DEFINED",
          "Safety": "NOT_DEFINED",
          "Automatable": "NOT_DEFINED",
          "Recovery": "NOT_DEFINED",
          "valueDensity": "NOT_DEFINED",
          "vulnerabilityResponseEffort": "NOT_DEFINED",
          "providerUrgency": "NOT_DEFINED"
        }
      }
    ],
    "ssvcV203": [
      {
        "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
        "ssvcData": {
          "timestamp": "2025-09-10T17:21:15.006896Z",
          "id": "CVE-2025-59042",
          "options": [
            {
              "exploitation": "none"
            },
            {
              "automatable": "no"
            },
            {
              "technicalImpact": "total"
            }
          ],
          "role": "CISA Coordinator",
          "version": "2.0.3"
        }
      }
    ]
  },
  "weaknesses": [
    {
      "source": "[email protected]",
      "type": "Secondary",
      "description": [
        {
          "lang": "en",
          "value": "CWE-94"
        }
      ]
    }
  ],
  "references": [
    {
      "url": "https://github.com/pyinstaller/pyinstaller/commit/f5adf291c8b832d5aff7632844f7e3ddf7ad4923",
      "source": "[email protected]"
    },
    {
      "url": "https://github.com/pyinstaller/pyinstaller/security/advisories/GHSA-p2xp-xx3r-mffc",
      "source": "[email protected]"
    }
  ]
}