pickle
A built-in Python standard library module for object serialization. It converts Python objects into byte streams for persistent storage and supports most built-in Python types. It serves as the most fundamental serialization tool in the Python ecosystem.
Core Facts
Timeline (last 90 days)
Model weight files may be implanted with malicious code, for example executing arbitrary commands through pickle deserialization vulnerabilities.
pickle is a Python built-in standard library used to serialize most Python objects, but it is slow when handling large numpy arrays and is unsuitable for big data scenarios.
pickle implements serialization by converting Python objects into a byte stream, a process called pickling, with the reverse recovery called unpickling.
If a model internally contains large numpy arrays (as is common with scikit-learn models), joblib has advantages over pickle in both speed and reliability.
A large number of existing models are still distributed in pickle format (.pkl, .pt, .bin), making static scanning before ingestion (e.g., with the picklescan tool) a necessary line of defense.
For platforms such as Hugging Face, attacks have been historically documented in which arbitrary code execution is triggered during model loading via malicious pickle files.
Hugging Face supports using the safetensors format as a replacement for the pickle format.
Prioritizing safetensors over pickle format when loading models can eliminate the risk of deserialization code execution at the source.
All Facts (12)
Python's pickle format can execute arbitrary code during deserialization, allowing attackers to embed malicious code in model files.
80%UnverifiedFor platforms such as Hugging Face, attacks have been historically documented in which arbitrary code execution is triggered during model loading via malicious pickle files.
60%UnverifiedModel weight files may be implanted with malicious code, for example executing arbitrary commands through pickle deserialization vulnerabilities.
50%Unverifiedpickle is a Python built-in standard library used to serialize most Python objects, but it is slow when handling large numpy arrays and is unsuitable for big data scenarios.
50%UnverifiedIf a model internally contains large numpy arrays (as is common with scikit-learn models), joblib has advantages over pickle in both speed and reliability.
50%Unverifiedpickle implements serialization by converting Python objects into a byte stream, a process called pickling, with the reverse recovery called unpickling.
50%UnverifiedA large number of existing models are still distributed in pickle format (.pkl, .pt, .bin), making static scanning before ingestion (e.g., with the picklescan tool) a necessary line of defense.
50%UnverifiedPrioritizing safetensors over pickle format when loading models can eliminate the risk of deserialization code execution at the source.
50%UnverifiedHugging Face supports using the safetensors format as a replacement for the pickle format.
50%UnverifiedPyTorch的.pt/.pth文件和许多框架的checkpoint依赖pickle进行序列化存储
50%Unverified应使用安全的序列化格式如safetensors而非pickle,并对拉取的模型进行完整性校验
50%UnverifiedThe deep learning community has long shared model weights in pickle format (.pt, .pkl files), and safer formats such as safetensors are being promoted as replacements.
50%