Downloads · 30 days
0
htdy7703/onnx-save-model-file-like-external-write-poc
onnx-save-model-file-like-external-write-poc is a machine learning model from htdy7703. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This PoC demonstrates a verified ONNX issue in the shipped onnx 1.22.0 wheel:
Downloads · 30 days
0
Access
Public
Updated Jul 8, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md1.6 KB · 34%
From the Hugging Face model README
This PoC demonstrates a verified ONNX issue in the shipped onnx 1.22.0 wheel:
onnx.save_model()all_tensors_to_one_file=False, attacker-controlled tensor names become sidecar filenames and attacker-controlled tensor bytes are appended to the matching local filerepro.py: end-to-end reproducer that builds the malicious ONNX model in memory, saves it to a file-like wrapper, and proves local .env corruption in the current working directoryREADME.md: impact summary and usage notesThe PoC creates a benign local .env file, builds an ONNX model whose initializer is also named .env, and then calls:
onnx.save_model(
model,
FileStorage(stream=io.BytesIO(), filename="output.onnx", name="file"),
save_as_external_data=True,
all_tensors_to_one_file=False,
size_threshold=0,
)
Because ONNX trusts the wrapper .name metadata as if it were a real model path, the external-data write is anchored to the current working directory instead of an explicit trusted export directory. The local .env file ends up containing the appended attacker payload.
python repro.py
Expected signal:
wrapper name: filecwd files: ['.env']appended payload: True