Downloads · 30 days
0
pragnyanramtha/onnxruntime-sparse-external-data-bypass-poc
onnxruntime-sparse-external-data-bypass-poc is a machine learning model from pragnyanramtha. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for onnx. The card lists the license as apache-2.0.
Benign security proof-of-concept for an ONNX Runtime external-data validation gap in sparse TensorProto conversion paths.
Downloads · 30 days
0
Access
Public
Updated May 12, 2026
Repo size
5.2 KB
Likes
0
Public
Click a slice to open those files.
.txt14.3 KB · 36%
From the Hugging Face model README
Benign security proof-of-concept for an ONNX Runtime external-data validation gap in sparse TensorProto conversion paths.
ONNX Runtime 1.26.0 validates external data paths for ordinary graph initializers, but two sparse TensorProto paths read external data before that initializer-validation loop covers them:
Constant node with a sparse_value attribute whose sparse values TensorProto uses external data.GraphProto.sparse_initializer whose sparse values TensorProto uses external data.For both paths, default onnxruntime.InferenceSession(model_path) reads external bytes and returns the marker as model output for malicious locations including:
../outside_dir/marker.binoutside_dir/marker.binlink_parent/marker.binhardlink.binONNX 1.21.0 checker rejects the malicious variants, so this is a checker/runtime mismatch and an apparent incomplete fix adjacent to ONNX Runtime's earlier external-data traversal fix.
Medium, CVSS 6.5.
Rationale: default runtime local file read through untrusted ONNX model loading. This is not RCE, and the attacker needs the ORT process to have read access to the target file and to shape offset, length, dtype, and graph output for the read.
onnxruntime==1.26.0onnx==1.21.0modelscan==0.8.8sparse_constant/verify.py: Generates and verifies the Constant(sparse_value=...) variant.sparse_initializer/verify.py: Generates and verifies the GraphProto.sparse_initializer variant.verify_all.py: Runs both variants and summarizes impact lines.results/: Captured local runtime and ModelScan outputs from research.requirements.txt: Tested dependency versions.The verifier scripts generate PoC models locally so absolute-path cases remain valid after download.
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
python verify_all.py
Expected result:
all_passed: truesparse_constant impact contains sparse_constant_external_data_bypasssparse_initializer impact contains sparse_initializer_external_data_bypassYou can also run each variant directly:
python sparse_constant/verify.py
python sparse_initializer/verify.py
For malicious sparse external-data variants, the expected behavior is:
onnx.checker.check_model(path) rejects ../, absolute path, parent symlink, and hardlink variants.onnxruntime.InferenceSession(path) returns the marker:
ORT_SPARSE_CONSTANT_EXT_READ for the sparse Constant variant.ORT_SPARSE_INITIALIZER_EXT_READ for the sparse initializer variant.onnxruntime.InferenceSession(model_bytes, SessionOptions(...folder_path...)) also returns the marker.ModelScan 0.8.8 skips .onnx files as unsupported. The main claim is ONNX checker versus ONNX Runtime default loader behavior.
A malicious ONNX model can use sparse TensorProto external data to make ONNX Runtime read local files outside the model directory during default model loading/inference. The attacker controls the external data location, offset, length, dtype, and graph output shape.
The PoC is benign and reads only controlled marker files generated in the local PoC directory.
Apply the same external-data validation used for ordinary graph initializers to sparse TensorProto values before any external data is opened. Cover Constant node sparse_value attributes and GraphProto.sparse_initializer conversion paths, including ../, absolute paths, symlinks, parent-directory symlinks, and hardlinks.