Описание
Wheel Affected by Arbitrary File Permission Modification via Path Traversal in wheel unpack
Summary
- Vulnerability Type: Path Traversal (CWE-22) leading to Arbitrary File Permission Modification.
- Root Cause Component: wheel.cli.unpack.unpack function.
- Affected Packages:
- wheel (Upstream source)
- setuptools (Downstream, vendors wheel)
- Severity: High (Allows modifying system file permissions).
Details
The vulnerability exists in how the unpack function handles file permissions after extraction. The code blindly trusts the filename from the archive header for the chmod operation, even though the extraction process itself might have sanitized the path.
PoC
I have confirmed this exploit works against the unpack function imported from setuptools._vendor.wheel.cli.unpack.
Prerequisites: pip install setuptools
Step 1: Generate the Malicious Wheel (gen_poc.py)
This script creates a wheel that passes internal hash validation but contains a directory traversal payload in the file list.
Step 2: Run the Exploit (exploit.py)
result:
Impact
Attackers can craft a malicious wheel file that, when unpacked, changes the permissions of critical system files (e.g., /etc/passwd, SSH keys, config files) to 777. This allows for Privilege Escalation or arbitrary code execution by modifying now-writable scripts.
Recommended Fix
The unpack function must not use zinfo.filename for post-extraction operations. It should use the sanitized path returned by wf.extract().
Suggested Patch:
Ссылки
- https://github.com/pypa/wheel/security/advisories/GHSA-8rrh-rw8j-w5fx
- https://nvd.nist.gov/vuln/detail/CVE-2026-24049
- https://github.com/pypa/wheel/commit/7a7d2de96b22a9adf9208afcc9547e1001569fef
- https://github.com/pypa/wheel/commit/934fe177ff912c8e03d5ae951d3805e1fd90ba5e
- https://github.com/pypa/wheel/releases/tag/0.46.2
Пакеты
wheel
>= 0.40.0, <= 0.46.1
0.46.2
Связанные уязвимости
wheel is a command line tool for manipulating Python wheel files, as defined in PEP 427. In versions 0.40.0 through 0.46.1, the unpack function is vulnerable to file permission modification through mishandling of file permissions after extraction. The logic blindly trusts the filename from the archive header for the chmod operation, even though the extraction process itself might have sanitized the path. Attackers can craft a malicious wheel file that, when unpacked, changes the permissions of critical system files (e.g., /etc/passwd, SSH keys, config files), allowing for Privilege Escalation or arbitrary code execution by modifying now-writable scripts. This issue has been fixed in version 0.46.2.
wheel is a command line tool for manipulating Python wheel files, as defined in PEP 427. In versions 0.40.0 through 0.46.1, the unpack function is vulnerable to file permission modification through mishandling of file permissions after extraction. The logic blindly trusts the filename from the archive header for the chmod operation, even though the extraction process itself might have sanitized the path. Attackers can craft a malicious wheel file that, when unpacked, changes the permissions of critical system files (e.g., /etc/passwd, SSH keys, config files), allowing for Privilege Escalation or arbitrary code execution by modifying now-writable scripts. This issue has been fixed in version 0.46.2.
wheel is a command line tool for manipulating Python wheel files, as d ...