Loading external model weights can introduce code-execution risk when the serialization format permits executable code. SafeTensors stores numeric tensor data without embedding executable code, making it an alternative to pickle-based model files. section 4.4.4 section 4.4.4
A safer file format does not secure the entire supply chain. In April 2024, researchers found that Hugging Face’s SafeTensor conversion service could be exploited to inject malicious code. An attacker who compromised the conversion bot’s credentials could push modified files under a trusted account. Hugging Face addressed the vulnerability. section 4.3.3
Before loading an external model, use the format as one control within a broader workflow:
- Check the publisher, review the model card and configuration files, and verify the file hash against the official release. section 4.4.4
- Require SafeTensors or a similar numeric-weights format, and record the downloaded file, its source, and its approver. section 4.4.4
- Test model behavior after introduction or updates; for stronger containment, use a restricted runtime and control model versions. section 4.4.4
Policy for external weights
An internal tool requires SafeTensors, verifies weights cryptographically against the publisher’s release, and runs them in a sandbox with network egress disabled by default. section 4.9
