The vulnerability, GHSA-6556-fwc2-fg2p, describes a bypass in the picklescan scanner that allows a malicious pickle to go undetected. The exploit uses the numpy.f2py.crackfortran._eval_length function, which can execute arbitrary code. The scanner failed to identify this as a threat.
The analysis of the patch in commit 70c1c6c31beb6baaf52c8db1b6c3c0e84a6f9dab reveals two key changes in src/picklescan/scanner.py:
-
The _unsafe_globals dictionary, which serves as a blocklist, was updated to include "numpy.f2py": "*". This marks the entire numpy.f2py module and all its submodules and functions as dangerous.
-
The core of the vulnerability within the scanner's code was in the _build_scan_result_from_raw_globals function. Its logic for checking if a submodule belongs to a blocked parent module was insufficient. The patch replaces the simplistic check with a loop that iterates through all parent parts of a module path (e.g., for a.b.c, it checks a and a.b).
This flawed logic in _build_scan_result_from_raw_globals is the root cause of the vulnerability. When scanning a pickle containing the malicious gadget, this function would be called and would fail to correctly identify the threat, returning a 'safe' result. Therefore, scanner._build_scan_result_from_raw_globals is the primary vulnerable function that would appear in a runtime profile during the scanning process.