1. Architecture and scope
A model artifact can include weights, configuration, tokenizer files and executable loader code. Safetensors is designed for tensor storage, while Python pickle can execute arbitrary code during unpickling. A data-focused tensor format addresses one loading path; it does not make accompanying Python code trustworthy. [1] [2] [3]
The Hugging Face loading guide describes explicit opt-in for custom model code and recommends selecting a specific revision. Separately, a checksum can show that bytes match an expected digest. If the expected digest comes from the same compromised place as the file, equality alone does not establish who produced those bytes. [3] [4]
Scope. A local artifact-review decision model and harmless byte hashes. No model is downloaded, deserialized or executed.
Workflow and scope notes
- Identify artifact. Record where the artifact came from and which files will be consumed. A display name or filename is not a complete provenance record.
- Fix version. Select a specific revision and obtain a trusted expected digest. A moving branch can change; pinning still does not prove the chosen revision benign.
- Review load path. Inspect whether deserialization or custom code can execute behavior. Tensor data and accompanying executable code require separate analysis.
- Controlled review. Compare digests and apply the declared local review policy. The toy’s best outcome remains a candidate for controlled review, never guaranteed safe.
2. Artifact review decisions
Toggle four declared facts. A digest mismatch stops the toy workflow. Pickle or custom code requires code-execution review. An unpinned revision needs provenance review. Otherwise the result is a candidate for controlled loading review.
Artifact review decisions
Original synthetic experiment · Change an input to update the figure.
The outcome is an author-defined review policy, not a malware detector, signature verifier or safety certification. The example’s digest is calculated over literal local bytes; no external artifact is opened.
Calculation record
{
"inputs": {
"format": "safetensors",
"custom": "no",
"pinned": "yes",
"hash": "yes"
},
"outcome": "Candidate for controlled review"
}| Case | Result | Interpretation |
|---|---|---|
| Digest mismatch | Stop | Do not treat a file with unexpected bytes as the reviewed artifact. |
| Pickle or custom code | Code-execution review | Pinning and digest equality do not remove executable behavior. |
| Pinned data-only path; digest matches | Candidate for controlled review | Authenticity, loader behavior and downstream model behavior remain separate questions. |
3. Interpretation and limitations
Python’s warning is about what unpickling can execute. Renaming a pickle file does not change that behavior. The format control describes the actual loading path assumed by the toy, not the file extension. The displayed code hashes bytes and never deserializes them. [2]
The 2023 safetensors audit announcement explicitly acknowledges that absence of flaws cannot be proved. That historical review is evidence about a specific review effort, not a promise about all future versions or all content shipped beside weights. The diagram keeps executable custom code on a separate review lane. [1] [3]
Editorial artifact record: publisher identity, immutable revision, exact file list, expected digests and their trusted origin, loader version, custom code review and intended execution boundary. A checksum comparison supports byte identity under its assumptions; it does not evaluate model behavior or licensing. [3] [4]
Keep safetensors selected and turn custom code on. Explain why that changes the review outcome even when the revision is pinned and the bytes match. Then change only the digest result and describe the first failing boundary.
4. Worked Python example
The core calculation below uses only the Python standard library. The full download adds the verification assertions and input fixtures. It runs locally on synthetic data; it does not load a model or contact a service.
from hashlib import sha256
from itertools import product
def review(format, custom, pinned, matches):
if not matches:
return "Stop: digest mismatch"
if format == "pickle" or custom:
return "Code-execution review"
if not pinned:
return "Provenance review"
return "Candidate for controlled review"
# Hash literal bytes only. No loading, unpickling or remote execution.
payload = b"synthetic tensor bytes for notebook only"
expected = sha256(payload).hexdigest()
assert sha256(payload).hexdigest() == expected
assert sha256(payload + b"changed").hexdigest() != expected
Download full Python example and checks ↓
Run: python -I lab.py. Recorded run: Python 3.13; 16 fixture states plus scenario assertions passed. The JSON output is a reproducibility record, not a real-system benchmark.
5. Questions and explanations
Predict before opening the explanation. Answers refer to the stated scope and synthetic inputs.
References and source links
- Hugging Face / EleutherAI / Stability AI authors. (2023). 🐶Safetensors audited as really safe and becoming the default.https://huggingface.co/blog/safetensors-security-audit
- Python Software Foundation. (Python 3.13.18 documentation). pickle — Python object serialization — Python 3.13.18 documentation.https://docs.python.org/3.13/library/pickle.html
- Hugging Face maintainers. (Transformers v5.5.2). Loading models · Hugging Face.https://huggingface.co/docs/transformers/v5.5.2/en/models
- Python Software Foundation. (Python 3.13.18 documentation). hashlib — Secure hashes and message digests — Python 3.13.18 documentation.https://docs.python.org/3.13/library/hashlib.html
Source checks and provenance
Primary publisher pages and relevant passages checked on 13 Nov 2026. Source support is not independent expert fact verification. Main documentation can change; retrieved-body hashes, dates, version labels and saved revision IDs are in the audit download.
Evidence: What is safetensors?; The security audit. A historical audit report announcement; not a guarantee for every version, model or loader.
Public ResearchNode original e9409320abb4181ca2f3cd5138dfebe9
Revision 8ddc8d11334f7341d1088ee1fbb9e4b3. Captured 2026-11-06.
Evidence: Warning at the start of pickle documentation. The example never imports pickle or deserializes external bytes.
Evidence: Custom models. Remote custom code and revision selection are separate from the tensor storage format.
Evidence: Hash algorithms; Usage. A digest checks bytes against a trusted expected value; publisher authenticity requires a separate trust decision.