Views
No views yet
unsafe_globals blocklist has systemic gaps allowing arbitrary code execution via crafted PyTorch .pt model files that scan clean. Four independent bypass chains are demonstrated, each requiring a different blocklist addition to fix.modelscan/tools/picklescanner.py) extracts GLOBAL/INST/STACK_GLOBAL opcodes and checks them against unsafe_globals in settings.py. The blocklist covers os, subprocess, builtins.eval, builtins.exec, operator.attrgetter, etc. — but misses 5 critical modules/functions that chain to full RCE:| Missing Entry | Why It's Dangerous |
|---|---|
importlib.import_module | Imports ANY blocked module (os, subprocess, etc.) at runtime |
operator.methodcaller | Calls any method on any object — chains with imported modules |
code.InteractiveConsole | Executes arbitrary Python source code |
io.open | Arbitrary file creation/overwrite |
codecs.open | Arbitrary file creation/overwrite |
operator.methodcaller('system', cmd)(importlib.import_module('os'))operator.methodcaller('push', 'import os; os.system(cmd)')(code.InteractiveConsole())io.open('/path/to/file', 'w')codecs.open('/path/to/file', 'w')1pip install torch modelscan
2python poc.pytorch.load(file, weights_only=False)