Downloads · 30 days
0
jeikei97/modelscan-pytorch-zip-gadget-chain-bypass
modelscan-pytorch-zip-gadget-chain-bypass is a machine learning model from jeikei97. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a proof of concept for a scanner bypass in modern ZIP-based PyTorch .pt model files.
Downloads · 30 days
0
Access
Public
Updated Jul 16, 2026
Repo size
811 B
Likes
1
Public
Click a slice to open those files.
.py4.7 KB · 44%
From the Hugging Face model README
This repository contains a proof of concept for a scanner bypass in modern ZIP-based PyTorch .pt model files.
The open-source protectai/modelscan scanner correctly opens ZIP-based PyTorch archives and scans the embedded data.pkl pickle. However, it still relies on a static unsafe-global blacklist, which can be bypassed by a higher-order gadget chain whose imported globals look benign.
The included payload uses only:
operator.methodcallerimportlib.import_moduleAt deserialization time, those globals compose into the equivalent of:
operator.methodcaller("system", "touch PT_MARKER.txt")(importlib.import_module("os"))
This means torch.load(..., weights_only=False) executes the payload even though modelscan reports zero issues and zero errors.
The main PoC file is:
artifacts/gadget_zip_pytorch.ptThe payload is harmless. When loaded through the unsafe path, it creates a local marker file:
PT_MARKER.txtartifacts/gadget_zip_pytorch.ptartifacts/reproduce_output.txtartifacts/sha256sums.txtreproduce.pymodelscan: protectai/modelscan @ 61fcec9c2a37c24c1fb12d84ede30fe248a364bdRun:
python reproduce.py --modelscan-path /path/to/modelscan
If modelscan is already installed in your environment, --modelscan-path is optional.
Expected results:
modelscan returns zero issues and zero errorstorch.load(..., weights_only=False) loads successfullyPT_MARKER.txtOrderedDict.pt templateRun:
python reproduce.py --build --template-pt /path/to/clean_zip_pytorch.pt --modelscan-path /path/to/modelscan
The clean template must be a ZIP-based PyTorch archive with a data.pkl member. This regenerates artifacts/gadget_zip_pytorch.pt and reruns the verification steps.
Recent PyTorch versions changed the default torch.load behavior to weights_only=True, which blocks unsafe globals earlier in the load pipeline.
The vulnerable / unsafe path demonstrated here is:
torch.load(path, weights_only=False)
That is the deserialization-equivalent path relevant to file-format ACE discussions and to environments that explicitly disable the safer default or use older behavior.
From artifacts/reproduce_output.txt:
modelscan_issue_count: 0modelscan_errors: []torch_load_type: OrderedDicttorch_load_keys: []marker_exists_after_torch_load: TrueThis is a practical semantic scanner bypass for a real PyTorch archive format:
.pt model artifactmodelscan inspects the embedded data.pkl