AIsbom – open-source CLI to detect "Pickle Bombs" in PyTorch models
Posted by lab700xdev 17 hours ago
Comments
Comment by lab700xdev 17 hours ago
I’ve been working with ML infrastructure for a while and realized there’s a gap in the security posture: we scan our requirements.txt for vulnerabilities, but blindly trust the 5GB binary model files (.pt) we download from Hugging Face.
Most developers don't realize that standard PyTorch files are just Zip archives containing Python Pickle bytecode. When you run torch.load(), the unpickler executes that bytecode. This allows for arbitrary code execution (RCE) inside the model file itself - what security researchers call a "Pickle Bomb."
I built AIsbom (AI Software Bill of Materials) to solve this without needing a full sandbox.
How it works: 1. It inspects the binary structure of artifacts (PyTorch, Pickle, Safetensors) without loading weights into RAM. 2. For PyTorch/Pickles, it uses static analysis (via pickletools) to disassemble the opcode stream. 3. It looks for GLOBAL or STACK_GLOBAL instructions referencing dangerous modules like os.system, subprocess, or socket. 4. It outputs a CycloneDX v1.6 JSON SBOM compatible with enterprise tools like Dependency-Track. 5. It also parses .safetensors headers to flag "Non-Commercial" (CC-BY-NC) licenses, which often slip into production undetected.
It’s open source (Apache 2.0) and written in Python/Typer. Repo: https://github.com/Lab700xOrg/aisbom Live Demo (Web Viewer): https://aisbom.io
Why I built a scanner? https://dev.to/labdev_c81554ba3d4ae28317/pytorch-models-are-...
I’d love feedback on the detection logic (specifically safety.py) or if anyone has edge cases of weird Pickle protocols that break the disassembler.
Comment by yjftsjthsd-h 16 hours ago
I thought the ecosystem had mostly moved to .safetensors (which was explicitly created to fix this problem) and .gguf (which I'm pretty sure also doesn't have this problem); do you really need to download giant chunks of untrusted code and execute it at all?
Comment by lab700xdev 15 hours ago
Comment by altomek 13 hours ago
Comment by solarengineer 10 hours ago
Comment by ivape 15 hours ago
Comment by lab700xdev 15 hours ago
Comment by ivape 15 hours ago
Comment by lab700xdev 14 hours ago
Comment by dylan604 15 hours ago
Comment by anky8998 4 hours ago
One thing we ran into while working on similar problems is that static opcode scanning alone tends to give a false sense of coverage. A lot of real-world bypasses don’t rely on obvious GLOBAL os.system patterns and can evade tools that depend on pickletools, modelscan, or fickling.
We recently open-sourced a structure-aware pickle fuzzer at Cisco that’s designed specifically to test the robustness of pickle scanners, not just scan models:
• It executes pickle bytecode inside a custom VM, tracking opcode execution, stack state, and memo behavior • Mutates opcode sequences, stack interactions, and protocol-specific edge cases • Has already uncovered multiple scanner bypasses that look benign statically but behave differently at runtime
Repo: https://github.com/cisco-ai-defense/pickle-fuzzer
We also wrote up some of the lessons learned while hardening pickle scanners here (including why certain opcode patterns are tricky to reason about statically): https://blogs.cisco.com/ai/hardening-pickle-file-scanners
I think tools like AIsbom are a great step forward, especially for SBOM and ecosystem visibility. From our experience, pairing static analysis + fuzzing-driven adversarial testing is where things get much more resilient over time.
Comment by rafram 17 hours ago
This seems like a doomed approach. You can’t make a list of every “dangerous” function in every library.
Comment by lab700xdev 16 hours ago
Comment by oofbey 16 hours ago
Comment by pama 16 hours ago
Comment by lab700xdev 16 hours ago
Comment by woodrowbarlow 16 hours ago
is anyone calling it that? to me, "pickle bomb" would imply abusing compression or serialization for a resource-exhaustion attack, a la zipbombs.
"pickle bomb", the way you're using it, doesn't seem like a useful terminology -- pickles are just (potentially malicious) executables.
Comment by lab700xdev 15 hours ago
Comment by nextaccountic 15 hours ago
This is outrageous. Why not deprecate this cursed format and use something from the data frame community? Like, Parquet or something
Actually almost any binary format is better than this
Comment by tennysont 15 hours ago
Safetensors is supposed to be the successor for distribution. I believe that it's the "safe" subset of pickle's data format.
Comment by rhdunn 13 hours ago
Comment by oofbey 16 hours ago
Comment by lab700xdev 16 hours ago
Comment by woodruffw 17 hours ago
[1]: https://github.com/Lab700xOrg/aisbom/blob/main/aisbom/safety...
Comment by lab700xdev 16 hours ago
Comment by liuliu 13 hours ago
Comment by liuliu 15 hours ago
Comment by chuckadams 17 hours ago
I somehow doubt this tool is going to be able to pull off what Java bytecode verification could not.
Comment by nextaccountic 15 hours ago
I thought the rule was, never use pickle, it makes no sense when other serialization formats exist and are just as easy to use
Comment by lab700xdev 16 hours ago
Comment by krick 7 hours ago
Comment by roywiggins 14 hours ago
Comment by xpe 13 hours ago
Many people prefer human writing. I get it, and I think I understand most of the underlying reasons and emotional drives. [1]
Nevertheless, my top preference (I think?) is clarity and accuracy. For technical writing, if these two qualities are present, I'm rarely bothered by what people may label "AI writing". OTOH, when I see sloppy, poorly reasoned, out-of-date writing, my left hand readies itself for ⌘W. [2]
A suggestion for the comment above, which makes a stylistic complaint: be more specific about what can be improved.
Finally, a claim: over time, valid identification of some text as being AI-generated will require more computation and be less accurate. [3]
[1]: Food for thought: https://theconversation.com/people-say-they-prefer-stories-w... and the backing report: https://docs.iza.org/dp17646.pdf
[2]: To be open, I might just have a much higher than average bar for precision -- I tend to prefer reading source materials than derivative press coverage, and I prefer reading a carefully worded, dry written documentation file over an informal chat description. To keep digging the hole for myself, I usually don't like the modern practice of putting unrelated full-width pictures in blog posts because they look purdy. Maybe it comes from a "just the facts, please" mentality when reading technical material.
[3]: I realize this isn't the clearest testable prediction, but I think the gist of it is falsifiable.
Comment by eyeris 5 hours ago
Comment by esafak 15 hours ago