You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Safetensors TOCTOU PoC

Security research โ€” TOCTOU race condition in safetensors PyTorch loading

This repository demonstrates a validation bypass vulnerability in the safetensors library. The Python bindings open the model file twice during PyTorch loading (once for Rust validation, once for PyTorch's UntypedStorage.from_file()), creating a TOCTOU window where the file can be swapped between validation and data loading.

Files

  • model.safetensors โ€” Clean model file (benign weights)
  • model_benign.safetensors โ€” Benign weights (class 0 classifier)
  • model_poison.safetensors โ€” Poisoned weights (backdoored to class 1)
  • exploit_symlink.py โ€” PoC exploit via symlink swap (99.4% success rate)
  • exploit_race.py โ€” PoC exploit via atomic file rename (58% success rate)
  • create_model.py โ€” Script to regenerate model files

Reproduction

pip install safetensors torch
python create_model.py
python exploit_symlink.py

Affected

  • safetensors <= 0.7.0 (all versions with PyTorch >= 1.11.0)
  • All downstream: transformers, diffusers, accelerate, etc.
Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
10 params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support