Unsafe Deserialization in AI Frameworks: Why Loading a Model or Checkpoint Can Run Code
For executives
In AI software, loading a file can mean running code. Python's pickle format, which sits under PyTorch checkpoints and many model, tokenizer and dataset files, rebuilds objects by calling functions named inside the file. A crafted checkpoint, configuration file or message therefore runs the attacker's code the moment a framework loads it. This is the single most common vulnerability class in NVIDIA's AI software: its 2026 CVE index lists 81 deserialization of untrusted data flaws (CWE-502), up from 9 in 2025, across Megatron, NeMo, TensorRT-LLM, Model Optimizer, Apex, Dynamo, NVFlare and more. The code runs inside the training or inference process, with its GPU access, its credentials and its data, and nothing about it looks like an intrusion from outside.
Why this is an AI runtime problem
AI work moves large, complex objects between systems all the time: checkpoints between training runs, fine-tuned weights between teams, tokenizers and datasets from public hubs, model updates between federated participants. The Python ecosystem made pickle the default way to save them because it serializes arbitrary objects with no extra code. A CPU application rarely loads executable state from a file a stranger produced. AI pipelines do it as routine, on machines that hold GPUs, model weights and cloud credentials.
How pickle turns a file into code
A pickle file is a small program for a stack-based virtual machine. When Python loads one, the file can tell the loader to import any module and call any function with arguments it supplies, through a method called reduce. A three-line payload that calls os.system is enough. Formats built on pickle inherit the behavior: PyTorch .pt and .pth checkpoints, many .pkl tokenizer and preprocessing files, and NumPy files loaded with allow_pickle.
Safer paths exist. PyTorch 2.6 made torch.load default to weights_only=True, which refuses arbitrary objects, and safetensors stores only tensors and metadata. They help only where the code uses them: NVIDIA's March 2026 Apex flaw (CVE-2025-33244, 9.0 Critical) affects environments running PyTorch earlier than 2.6, and its July 2026 TensorRT-LLM flaw (CVE-2026-24233, 8.4) sat in the restricted unpickler meant to make weight loading safe.
NVIDIA's 2026 CWE-502 CVEs by product
| Product family | CVEs | Bulletins |
|---|---|---|
| Megatron (Megatron Bridge and Megatron-LM) | 47 | Five, March to November; 30 in the September 2026 Megatron Bridge bulletin alone |
| NeMo (NeMo Framework, NeMo Speech, BioNeMo) | 15 | Six |
| TensorRT-LLM and TensorRT | 7 | Three |
| Merlin (NVTabular, Transformers4Rec) | 4 | Three |
| Model Optimizer | 3 | Three |
| Apex, DALI, Dynamo, NVFlare, Transformer Engine | 1 each | One each |
All but five are rated High; one is Critical (CVE-2025-33244 in Apex, 9.0). Most are scored as local attacks, because the victim has to load the file. In practice that means anyone who can place a file where a pipeline will load it: a shared checkpoint directory, a model hub, an object store or a dataset mount.
Notable examples
CVE-2025-33244: Apex (9.0 Critical)
Deserialization of untrusted data in NVIDIA Apex for Linux, where an unauthorized attacker could reach code execution in environments using PyTorch earlier than 2.6. Fixed in any branch that includes commit db8e053. Reported by Dan Aridor.
CVE-2026-24186: NVFlare FOBS (8.8 High)
Deserialization in FOBS, NVFlare's own serialization layer, reached by sending a crafted message. In federated learning, the sender is a provisioned participant, so the payload arrives through the same channel as legitimate model updates. Fixed in NVFlare 2.7.2.
CVE-2026-24233: TensorRT-LLM restricted unpickler (8.4 High)
A flaw in the restricted unpickler TensorRT-LLM uses for model weight deserialization, reachable by a local, unauthenticated attacker. Allow-list unpicklers reduce the risk; they are not a guarantee. Fixed in v1.3.0 rc15. Reported by k0x.
CVE-2026-65179: NeMo Speech TabularTokenizer (8.8 High)
The TabularTokenizer class loaded an attacker-controlled .pkl file with pickle.load() without validation. A tokenizer file is not something most teams treat as executable. Fixed in NeMo Speech 3.0.
CVE-2026-47623: Dynamo (8.2 High)
Deserialization of untrusted data in NVIDIA Dynamo, the distributed inference framework, which might lead to denial of service and data tampering. Fixed in v1.2.0.
CVE-2026-67455: Model Optimizer (8.8 High)
Deserialization in NVIDIA Model Optimizer for Linux and Windows, fixed in 0.44.0. Reported by Mohamed Lemine Ahmed Jidou (AegisSec).
Where the files come from
- Public model hubs: weights, tokenizers and configuration downloaded by name, often pinned to a tag rather than a hash.
- Shared storage: checkpoint directories on NFS, Lustre or object stores that many jobs and users can write to.
- Training pipelines: a compromised data-loading or preprocessing stage writes a poisoned checkpoint that a later job loads.
- Federated and distributed systems: messages between participants, workers or schedulers that are deserialized on arrival.
Detection
Scanning files before they load helps, and safe formats help more, but neither covers a library that calls pickle internally or a restricted unpickler with a bypass. The reliable signal is what happens at load time. A framework process that, while loading a checkpoint or tokenizer, imports modules it never imports during training or inference, calls exec or eval, starts a shell, opens network connections or loads unexpected CUDA libraries, is running code it was not written to run. Stealthium's Hands Off research tracks these entry points in Python GPU workloads (imports, .pth startup files, pickle model files, and exec and eval strings) and ties each to the Python call stack and the container that caused it.
Mitigation
- Patch the affected NVIDIA frameworks; most fixes are a release or a named commit.
- Run PyTorch 2.6 or later and keep torch.load with weights_only=True. Prefer safetensors for weights.
- Treat checkpoint, tokenizer and dataset locations as code repositories: restrict who can write, and verify hashes or signatures before loading.
- Never load pickled files from public hubs or other tenants into processes that hold credentials or shared GPUs.
Related articles
- Model file formats: pickle, .pt, safetensors and GGUF, and which ones can run code
- Megatron-LM and Megatron Bridge vulnerabilities
- NVFlare vulnerabilities, 2022 to 2026
- The AI software supply chain: images, packages, startup hooks and GPU binaries
- Hands Off: Detecting Model Weight Tampering (Stealthium research)