CVE-2025-1945: Picklescan Zip Flag Bit Exploit Crashes Vulnerability

MODERATE
Advisory Identifier: GHSA-w8jq-xcqf-f792
CWE-345
Published
Advisory Summary

CVE-2025-1945 is a MODERATE zip flag bit exploit crashes vulnerability (CWE-345: Insufficient Verification of Data Authenticity) affecting Picklescan libraries in the PyPI ecosystem. The issue involves zip flag bit exploit crashes picklescan but not pytorch. Remediation is available by upgrading affected packages to version 0.0.23.

CVE-2025-1945 at a Glance

CVE Identifier CVE-2025-1945
GHSA Identifier GHSA-w8jq-xcqf-f792
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-345: Insufficient Verification of Data Authenticity
Affected Product Picklescan
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-1945

To remediate this vulnerability, upgrade all affected Picklescan dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

picklescan fixed: 0.0.23
pip install picklescan>=0.0.23
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show picklescan

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-1945, inspect your installed packages using pip:

pip show picklescan

Analyze the terminal output to locate any version of Picklescan in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.23), your application is affected.

Note: The pip show picklescan command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-345: Insufficient Verification of Data Authenticity, where the product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data. In Picklescan, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary PickleScan fails to detect malicious pickle files inside PyTorch model archives when certain ZIP file flag bits are modified. By flipping specific bits in the ZIP file headers, an attacker can embed malicious pickle files that remain undetected by PickleScan while still being successfully loaded by PyTorch's torch.load(). This can lead to arbitrary code execution when loading a compromised model. ### Details PickleScan relies on Python’s zipfile module to extract and scan files within ZIP-based model archives. However, certain flag bits in ZIP headers affect how files are interpreted, and some of these bits cause PickleScan to fail while leaving PyTorch’s loading mechanism unaffected. By modifying the flag_bits field in the ZIP file entry, an attacker can: - Embed a malicious pickle file (bad_file.pkl) in a PyTorch model archive. - Flip specific bits (e.g., 0x1, 0x20, 0x40) in the ZIP metadata. - Prevent PickleScan from scanning the archive due to errors raised by zipfile. - Successfully load the model with torch.load(), which ignores the flag modifications. This technique effectively bypasses PickleScan's security checks while maintaining model functionality. ### PoC ``` import os import zipfile import torch from picklescan import cli def can_scan(zip_file): try: cli.print_summary(False, cli.scan_file_path(zip_file)) return True except Exception: return False bit_to_flip = 0x1 # Change to 0x20 or 0x40 to test different flag bits zip_file = "model.pth" model = {'a': 1, 'b': 2, 'c': 3} torch.save(model, zip_file) with zipfile.ZipFile(zip_file, "r") as source: flipped_name = f"flipped_{bit_to_flip}_{zip_file}" with zipfile.ZipFile(flipped_name, "w") as dest: bad_file = zipfile.ZipInfo("model/bad_file.pkl") # Modify the ZIP flag bits bad_file.flag_bits |= bit_to_flip dest.writestr(bad_file, b"bad content") for item in source.infolist(): dest.writestr(item, source.read(item.filename)) if model == torch.load(flipped_name, weights_only=False): if not can_scan(flipped_name): print('Found exploitable bit:', bit_to_flip) else: os.remove(flipped_name) ``` ### Impact Severity: `High` - Who is impacted? Any organization or user relying on PickleScan to detect malicious pickle files inside PyTorch models. - What is the impact? Attackers can embed malicious pickle payloads inside PyTorch models that evade PickleScan's detection but still execute upon loading. - Potential Exploits: This vulnerability could be exploited in machine learning supply chain attacks, allowing attackers to distribute backdoored models on platforms like Hugging Face or PyTorch Hub. ### Recommendations - Improve ZIP Handling: PickleScan should use a more relaxed ZIP parser marches on when encountering modified flag bits. - Scan All Embedded Files Regardless of Flags: Ensure that files with altered metadata are still extracted and analyzed. By addressing these issues, PickleScan can provide stronger protection against manipulated PyTorch model archives.

CVE-2025-1945 Affected Picklescan Versions

1 component(s)
Fixed Versions:
0.0.23
Product / Package Ecosystem Affected Versions Fixed Version
picklescan
PyPI
< 0.0.23
0.0.23

References

Frequently Asked Questions

What is CVE-2025-1945?
CVE-2025-1945 is a security vulnerability in Picklescan involving Zip Flag Bit Exploit Crashes Picklescan But Not PyTorch under CWE-345: Insufficient Verification of Data Authenticity.
Which Picklescan versions are affected?
Affected versions include releases prior to 0.0.23 across affected packages: picklescan.
What version fixes CVE-2025-1945?
Upgrading to 0.0.23 (or the latest patched release for your respective branch) resolves the vulnerability.
Is picklescan affected?
Yes, picklescan is affected in releases prior to 0.0.23. Upgrade your dependency to 0.0.23 or later.
What CWE is associated with CVE-2025-1945?
CVE-2025-1945 is classified under CWE-345: Insufficient Verification of Data Authenticity (The product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.).
How can I check PyPI dependencies for CVE-2025-1945?
Run the dependency tree command: 'pip show picklescan'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w8jq-xcqf-f792",
  "modified" : "2025-04-09T20:13:19Z",
  "published" : "2025-03-10T18:26:35Z",
  "aliases" : [ "CVE-2025-1945" ],
  "summary" : "Zip Flag Bit Exploit Crashes Picklescan But Not PyTorch",
  "details" : "### Summary\n\nPickleScan fails to detect malicious pickle files inside PyTorch model archives when certain ZIP file flag bits are modified. By flipping specific bits in the ZIP file headers, an attacker can embed malicious pickle files that remain undetected by PickleScan while still being successfully loaded by PyTorch's torch.load(). This can lead to arbitrary code execution when loading a compromised model.\n\n### Details\n\nPickleScan relies on Python’s zipfile module to extract and scan files within ZIP-based model archives. However, certain flag bits in ZIP headers affect how files are interpreted, and some of these bits cause PickleScan to fail while leaving PyTorch’s loading mechanism unaffected.\n\nBy modifying the flag_bits field in the ZIP file entry, an attacker can:\n\n- Embed a malicious pickle file (bad_file.pkl) in a PyTorch model archive.\n- Flip specific bits (e.g., 0x1, 0x20, 0x40) in the ZIP metadata.\n- Prevent PickleScan from scanning the archive due to errors raised by zipfile.\n- Successfully load the model with torch.load(), which ignores the flag modifications.\n\nThis technique effectively bypasses PickleScan's security checks while maintaining model functionality.\n\n### PoC\n```\nimport os\nimport zipfile\nimport torch\nfrom picklescan import cli\n\ndef can_scan(zip_file):\n    try:\n        cli.print_summary(False, cli.scan_file_path(zip_file))\n        return True\n    except Exception:\n        return False\n\nbit_to_flip = 0x1  # Change to 0x20 or 0x40 to test different flag bits\n\nzip_file = \"model.pth\"\nmodel = {'a': 1, 'b': 2, 'c': 3}\ntorch.save(model, zip_file)\n\nwith zipfile.ZipFile(zip_file, \"r\") as source:\n    flipped_name = f\"flipped_{bit_to_flip}_{zip_file}\"\n    with zipfile.ZipFile(flipped_name, \"w\") as dest:\n        bad_file = zipfile.ZipInfo(\"model/bad_file.pkl\")\n        \n        # Modify the ZIP flag bits\n        bad_file.flag_bits |= bit_to_flip\n        \n        dest.writestr(bad_file, b\"bad content\")\n        for item in source.infolist():\n            dest.writestr(item, source.read(item.filename))\n\nif model == torch.load(flipped_name, weights_only=False):\n    if not can_scan(flipped_name):\n        print('Found exploitable bit:', bit_to_flip)\nelse:\n    os.remove(flipped_name)\n```\n\n### Impact\n\nSeverity: `High`\n\n- Who is impacted? Any organization or user relying on PickleScan to detect malicious pickle files inside PyTorch models.\n- What is the impact? Attackers can embed malicious pickle payloads inside PyTorch models that evade PickleScan's detection but still execute upon loading.\n- Potential Exploits: This vulnerability could be exploited in machine learning supply chain attacks, allowing attackers to distribute backdoored models on platforms like Hugging Face or PyTorch Hub.\n\n### Recommendations\n\n- Improve ZIP Handling: PickleScan should use a more relaxed ZIP parser marches on when encountering modified flag bits.\n- Scan All Embedded Files Regardless of Flags: Ensure that files with altered metadata are still extracted and analyzed.\n\nBy addressing these issues, PickleScan can provide stronger protection against manipulated PyTorch model archives.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "picklescan"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.23"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mmaitre314/picklescan/security/advisories/GHSA-w8jq-xcqf-f792"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-1945"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mmaitre314/picklescan/commit/e58e45e0d9e091159c1554f9b04828bbb40b9781"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mmaitre314/picklescan"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/picklescan/PYSEC-2025-21.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://sites.google.com/sonatype.com/vulnerabilities/cve-2025-1945"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-345" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-03-10T18:26:35Z",
    "nvd_published_at" : null
  }
}