Downloads · 30 days
0
WolfpackArmy/safetensors-integer-overflow-poc
safetensors-integer-overflow-poc is a machine learning model from WolfpackArmy. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
CWE-190 / CWE-125: Integer overflow in TensorView::new() bypasses size validation.
Downloads · 30 days
0
Access
Public
Updated Apr 12, 2026
Repo size
104 B
Likes
0
Public
Click a slice to open those files.
.rs2.2 KB · 42%
From the Hugging Face model README
CWE-190 / CWE-125: Integer overflow in TensorView::new() bypasses size validation.
In safetensors/src/tensor.rs, lines 755-757:
let n_elements: usize = shape.iter().product(); // UNCHECKED - wraps on overflow
let nbits = n_elements * dtype.bitsize(); // UNCHECKED - wraps on overflow
The validate() method (lines 642-650) correctly uses checked_mul via try_fold,
but TensorView::new() does not. This inconsistency means any Rust consumer using
TensorView::new() directly is vulnerable.
poc_model.safetensors - Valid safetensors file (the file format itself is safe
because deserialization uses validate())overflow_poc.rs - Rust PoC demonstrating the API-level overflowOut-of-bounds memory read when sliced_data() is called on a TensorView constructed
with crafted shape dimensions that overflow usize. This affects any Rust crate that
calls TensorView::new() directly with user-controlled shape values.
SliceIterator::new() in slice.rs:362 uses unchecked span *= shape multiplication.
let n_elements: usize = shape
.iter()
.try_fold(1usize, |acc, &x| acc.checked_mul(x))
.expect("Shape dimensions overflow usize");