ModelScan Bypass PoC β typing+builtins.get_type_hints+type
Security research for responsible disclosure via Huntr MFV program.
Vulnerability
typing+builtins.get_type_hints+type is not in modelscan's unsafe_globals blocklist.
When a pickle file containing this global is scanned by modelscan, it reports "No issues found."
However, loading the file with pickle.loads() / torch.load() triggers FULL ARBITRARY CODE EXECUTION via eval() on type annotation strings.
Impact
- Severity: CRITICAL
- Effect: FULL ARBITRARY CODE EXECUTION via eval() on type annotation strings
Chain Details
builtins.type("X", (), {"__annotations__": {"x": "malicious_code"}})β creates class with string annotation.builtins.typeis NOT blocked (only eval/exec/getattr/etc are blocked from builtins).typing.get_type_hints(class)β internally callseval()on the annotation string, executing arbitrary Python code.- This is a two-step pickle chain achieving full RCE without using any blocked module.
Bypass Class
builtins.type: Not in blocked builtins list (modelscan blocks eval, compile, getattr, apply, exec, open, breakpoint, import but NOT type)typing.get_type_hints: Not in blocklist at all- Combined: full arbitrary code execution via eval()
Reproduction
pip install modelscan
modelscan scan -p bypass_poc.pkl
# Output: "No issues found!"
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support