Rahul Sharma | Senior Software Engineer, Red Hat | @rahulXs
- Quick Start - Sign Your First Model
- Demo Code (in this gist)
- Safety Checklist
- Open Source Projects (contribute!)
- CVEs & Security Advisories
- Research Papers
- Articles & Deep Dives
- Incident Timeline
- About Me
Three commands. No key management. No GPG. No certificate rotation.
pip install model-signing
model_signing sign ./my-model/
model_signing verify ./my-model/ \
--signature model.sig \
--identity "your-email@example.com" \
--identity_provider "https://accounts.google.com"- Signing authenticates via OIDC in your browser (Google/GitHub login).
- The signature is a detached Sigstore bundle (
model.sig) wrapping an in-toto attestation of SHA-256 hashes. - Verification works offline once you have the bundle.
The exact files from Demo 1; everything runs on localhost only, nothing leaves your machine:
| File | What it does |
|---|---|
create_demo_model.py |
Creates a small legitimate PyTorch model (the contrast) |
create_malicious_model.py |
Creates a .pt file with a reverse shell in __reduce__ (DEMO ONLY, connects to 127.0.0.1:9999) |
load_model.py |
Loads the model with weights_only=False - what legacy tutorials still teach |
Run it yourself (in a VM/container if you want to be extra safe):
mkdir -p models && cd oosc-demo
python create_demo_model.py
python create_malicious_model.py
# Terminal A (attacker): nc -l 9999
# Terminal B (victim): python load_model.pyHow it works:
torch.save()uses pickle internally. Duringtorch.load(), pickle calls__reduce__()to reconstruct objects, whatever it returns gets executed. Here that'sos.system(reverse_shell), backgrounded so the load "succeeds" silently. Not a bug - documented Python behavior. Python docs literally say "Never unpickle data from an untrusted source."
Do:
- Use SafeTensors for all new models — no pickle, no code execution on load
- Use
torch.load(..., weights_only=True)at minimum (default since PyTorch 2.6) - Sign models before sharing (
pip install model-signing) - Verify signatures before loading any model
- Pin models by commit hash, not branch name
Don't:
- Never disable safety flags (
weights_only=False) on untrusted files - Never set
trust_remote_code=Truewithout reading the code first - Never load pickle models outside a sandbox/VM if you can avoid it
- Never assume a scanner passing = file is safe (see ShadowPickle below)
All are beginner-friendly and accepting contributions:
| Project | Link | Why it matters |
|---|---|---|
| Model Signing (OMS) | https://github.com/sigstore/model-transparency | Sign/verify model artifacts. Implements the OpenSSF Model Signing spec. pip install model-signing |
| OMS Specification | https://github.com/ossf/model-signing-spec | The formal spec (June 2025), backed by Google, NVIDIA, HiddenLayer, Red Hat |
| SafeTensors | https://github.com/huggingface/safetensors | Safe serialization format tensors + JSON only, zero-copy. Joined PyTorch Foundation, Mar 2026 |
| Fickling | https://github.com/trailofbits/fickling | Pickle decompiler & safety analyzer by Trail of Bits. Inspect suspicious pickles without executing them |
| Sigstore | https://www.sigstore.dev/ | Keyless signing infra ("Let's Encrypt for code signing") Fulcio CA + Rekor transparency log |
| ID | What happened | Reference |
|---|---|---|
| CVE-2026-24747 | weights_only=True bypassed via heap corruption (type confusion in C++ restricted unpickler, SETITEM opcode). CVSS 8.8. Fixed in PyTorch 2.10.0 |
GHSA-63CW-57P8-FM3P · RAXE-2026-019 |
| CVE-2026-3490 | PickleScan blocklist universally bypassed via pkgutil.resolve_name("os:system") indirection; 11+ RCE chains all reported CLEAN |
GHSA-VVPJ-8CMC-GX39 · RAXE-2026-015 |
| CVE-2025-1716, -1889, -1944, -1945 | Four PickleScan zero-days | See timeline below |
Key takeaway: both the framework defense and the principal scanner were broken in 2026. You cannot blocklist your way out of a Turing-complete format. Defense = safer format + cryptographic verification.
- ShadowPickle: Evading ML Model Scanners via Stealthy Pickle Attacks (arXiv, Jul 2026) three novel attacks exploiting pickle's module import mechanism; best variant evades 63% of scanners including Hugging Face's. Introduces PickleBench. https://arxiv.org/html/2607.17503
- Exploiting Python pickling David Hamann's classic walkthrough of
__reduce__RCE (the technique behind our Demo 1). https://davidhamann.de/2020/04/05/exploiting-python-pickle/ - DEF CON 33: Loading Models, Launching Shells Cyrus Parzian, 2025. https://media.defcon.org/DEF%20CON%2033/DEF%20CON%2033%20presentations/
Model signing / Sigstore:
- An Introduction to the OpenSSF Model Signing (OMS) Specification - OpenSSF blog, Jun 2025 https://openssf.org/blog/2025/06/25/an-introduction-to-the-openssf-model-signing-oms-specification/
- Case Study: Google Secures ML Models with Sigstore - OpenSSF, Jul 2025 https://openssf.org/blog/2025/07/23/case-study-google-secures-machine-learning-models-with-sigstore/
- Model authenticity and transparency with Sigstore - Red Hat, Apr 2025 https://next.redhat.com/2025/04/10/model-authenticity-and-transparency-with-sigstore/
- Taming the Wild West of ML: Practical Model Signing with Sigstore — Sigstore blog https://blog.sigstore.dev/model-transparency-v1.0/
- model-signing on PyPI https://pypi.org/project/model-signing/
SafeTensors:
- SafeTensors joins the PyTorch Foundation - Hugging Face blog, Mar 2026 https://huggingface.co/blog/safetensors-joins-pytorch-foundation
- PyTorch Foundation announcement - PR Newswire, Apr 2026 https://www.prnewswire.com/news-releases/pytorch-foundation-announces-safetensors-as-newest-contributed-project-to-secure-ai-model-execution-302736068.html
- SafeTensors - official PyTorch ecosystem page https://pytorch.org/projects/safetensors/
Malicious models on Hugging Face:
- ReversingLabs identifies malware ML model on Hugging Face (nullifAI) - Feb 2025 https://www.reversinglabs.com/blog/rl-identifies-malware-ml-model-hosted-on-hugging-face
- The Poisoned Model Registry: Hugging Face as Malware Distribution Channel - Lyrie Research, 2026 https://lyrie.ai/research/research/huggingface-model-supply-chain-nullifai-pickle-rce
- Malicious AI Model Repositories Attack Surface - Cloud Security Alliance https://labs.cloudsecurityalliance.org/research/csa-research-note-malicious-ai-model-repositories-attack-sur/
- Poisoned AI: How Hugging Face Became a Malware Distribution Platform - Hive Security, 2026 https://hivesecurity.gitlab.io/blog/huggingface-ai-supply-chain-attacks-2026/
Senior Software Engineer at Red Hat. Builds Python and Go systems for RHEL and OpenShift; works on rule-driven diagnostics engines, multi-agent workflows, and more recently harness engineering.
- GitHub: https://github.com/rahulXs
- Slides PDF: Upcoming
Questions about the talk? Leave a comment on this gist, I'll try to answer.