Challenges
Safetensors: header metadata
Artificial Intelligence
Easy
ML file formats: analysing the binary header and metadata of HuggingFace Safetensors
Solves: 2
Safetensors: header metadata
Author: CyberSamSU
Points
15
A neural network model deployed to a production server was exported as the model.safetensors file. The developers gave up the pickle format and moved to the safe Safetensors format, but forgot to clean the training process configuration from the model header.
The Safetensors file format has the following structure:
- The first 8 bytes: a 64-bit unsigned little-endian integer (
uint64 LE) — the byte length of the JSON headerN. - The next N bytes: a JSON object in UTF-8 format (the
dtype,shape,data_offsetsproperties of the tensors and the__metadata__dictionary). - The remaining bytes: the buffer of raw tensor data.
In the __metadata__.training_run field of the header, a compressed training log in the form base64(gzip(json)) is stored. Note that decoy fake flags are present in the tensor buffer and in the canary_notice field. Open the real training_run object and find the BAYROQ{SAFETENSORS_META_...} flag (the last 16 characters are lowercase hex).
Attached files
model.safetensors
Log in to download
Theory: learn the topic
To submit a flag, log in.