Skip to content

Integrate huggingface/safetensors (Rust) - #16152

Open
ahkarl13 wants to merge 1 commit into
google:masterfrom
ahkarl13:add-safetensors-project
Open

ahkarl13 wants to merge 1 commit into
google:masterfrom
ahkarl13:add-safetensors-project

Conversation

@ahkarl13

Copy link
Copy Markdown

This adds an OSS-Fuzz integration for safetensors, the Rust crate used across the ML ecosystem to load model-weight files. It is not currently in OSS-Fuzz.

Target: a libFuzzer harness on SafeTensors::deserialize — the untrusted-input entry point that parses the 8-byte little-endian header length, the JSON metadata header, and each tensor's (dtype, shape, [begin,end)) offset descriptors against the backing buffer. The header-length / offset math is the classic out-of-bounds seam for memory-format deserializers.

Validated locally:

  • python3 infra/helper.py build_fuzzers --sanitizer address safetensors — builds clean.
  • python3 infra/helper.py run_fuzzer safetensors deserialize — ~353k exec/s over a 90s smoke run; the corpus reaches the header/offset parser (dictionary picks up data_offsets, dtype, shape, __metadata__). No crashes in the smoke run.

Details:

  • Language: Rust (cargo-fuzz), libFuzzer + AddressSanitizer, x86_64.
  • primary_contact / auto_ccs: ahkarl13@gmail.com

Adds an OSS-Fuzz project for the safetensors Rust crate, which is widely
used to load model-weight files across the ML ecosystem and is not
currently fuzzed.

A libFuzzer target exercises SafeTensors::deserialize, the untrusted-input
entry point that parses the 8-byte little-endian header length, the JSON
metadata header, and each tensor's (dtype, shape, offset) descriptors
against the backing buffer.

Built and run locally with infra/helper.py (build_fuzzers --sanitizer
address; run_fuzzer smoke test).
@google-cla

google-cla Bot commented Sep 18, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions

Copy link
Copy Markdown

ahkarl13 is integrating a new project:
- Main repo: https://github.com/huggingface/safetensors
- Criticality score: 0.48258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant