Skip to content

Instantly share code, notes, and snippets.

@rahulXs
Created August 24, 2026 15:40
Show Gist options
  • Select an option

  • Save rahulXs/33981c9d91701115bb44ac406396c782 to your computer and use it in GitHub Desktop.

Select an option

Save rahulXs/33981c9d91701115bb44ac406396c782 to your computer and use it in GitHub Desktop.
The AI Odyssey: When Your Model Is the Trojan Horse | OOSC 4.0 IIIT Allahabad | All resources

The AI Odyssey: When Your Model Is the Trojan Horse

All resources from my talk at OOSC 4.0 | IIIT Allahabad | Aug 28–30, 2026

Rahul Sharma | Senior Software Engineer, Red Hat | @rahulXs


Contents

  1. Quick Start - Sign Your First Model
  2. Demo Code (in this gist)
  3. Safety Checklist
  4. Open Source Projects (contribute!)
  5. CVEs & Security Advisories
  6. Research Papers
  7. Articles & Deep Dives
  8. Incident Timeline
  9. About Me

Quick Start - Sign Your First Model

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.

Demo Code (in this gist)

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.py

How it works: torch.save() uses pickle internally. During torch.load(), pickle calls __reduce__() to reconstruct objects, whatever it returns gets executed. Here that's os.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."


Safety Checklist

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=True without 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)

Open Source Projects (contribute!)

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

CVEs & Security Advisories

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.


Research Papers

Articles & Deep Dives

Model signing / Sigstore:

SafeTensors:

Malicious models on Hugging Face:


About Me

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.

Questions about the talk? Leave a comment on this gist, I'll try to answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment