Downloads · 30 days
0
htdy7703/pytorch-safe-globals-thread-leak-poc-20260709
pytorch-safe-globals-thread-leak-poc-20260709 is a machine learning model from htdy7703. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository demonstrates a concurrency-scoping bug in PyTorch's public torch.serialization.safeglobals(...) API.
Downloads · 30 days
0
Access
Public
Updated Jul 9, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py2 KB · 45%
From the Hugging Face model README
safe_globals cross-thread weights_only=True bypass PoCThis repository demonstrates a concurrency-scoping bug in PyTorch's public torch.serialization.safe_globals(...) API.
What this PoC shows:
torch.load(..., weights_only=True) blocks an attacker-controlled custom class by default.with torch.serialization.safe_globals([DangerousState]): open for a trusted load, an unrelated thread can load the same class without opting into safe_globals.__setstate__ during deserialization, proving code execution in that shared worker process.What this PoC does not show:
add_safe_globals(), which is already an explicit process-wide opt-in.pt load path is unsafe by defaultVerified runtime:
torch-2.13.0+cpu wheelRun:
python3 poc_safe_globals_thread_leak.py