Downloads · 30 days
0
pragnyanramtha/onnx-hash-symlink-helper-poc
onnx-hash-symlink-helper-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 a conditional ONNX external-data helper path issue.
Downloads · 30 days
0
Access
Public
Updated May 12, 2026
Repo size
10.5 KB
Likes
0
Public
Click a slice to open those files.
.py10.6 KB · 40%
From the Hugging Face model README
# Symlink PoCBenign security proof-of-concept for a conditional ONNX external-data helper path issue.
ONNX 1.21.0 rejects this model with default onnx.load(...), and ONNX Runtime 1.26.0 rejects it during InferenceSession(...). However, two public ONNX helper paths read the external data through a #-prefixed parent symlink when callers pass an empty base directory:
onnx.external_data_helper.load_external_data_for_model(model, base_dir="")onnx.numpy_helper.to_array(tensor, base_dir="")The common precondition is code that derives the base directory from a relative filename in the current working directory:
model_path = "poc_hash_external.onnx"
base_dir = os.path.dirname(model_path) # ""
The model-controlled external data location is:
#outside/marker.bin
The package supplies model_dir/#outside as a symlink to ../outside_dir. The helper path reads ONNX_HASH_SYMLINK_READ through that parent symlink.
Medium, CVSS 5.0.
Rationale: local file read through model-controlled ONNX external data, but only for explicit helper usage with base_dir="". Default onnx.load(...) and ONNX Runtime reject the same artifact in local validation.
onnx==1.21.0onnxruntime==1.26.0modelscan==0.8.8onnx_hash_symlink_case.tar: PoC package preserving the symlink relationship.verify_poc.py: Extracts the tar, verifies the helper/runtime behavior, and prints JSON evidence.make_poc.py: Rebuilds the PoC package files from scratch.verify_original.py: Original local verifier used during research.requirements.txt: Tested dependency versions.The tar archive contains:
model_dir/poc_hash_external.onnx
model_dir/#outside -> ../outside_dir
outside_dir/marker.bin
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
python verify_poc.py
Expected result:
symlink_exists: truesymlink_target: ../outside_direxternal_helper_relative_dirname.stdout contains ONNX_HASH_SYMLINK_READnumpy_helper_to_array_relative_dirname.stdout contains ONNX_HASH_SYMLINK_READonnx_load_default.returncode is non-zeroonnxruntime_file.returncode is non-zeroimpact: onnx_external_helpers_read_marker_through_hash_parent_symlinkf1402b58cb192a32d68bf3e20ed8a957d48865456921d460c2e3f3bbb8bccd27 onnx_hash_symlink_case.tar
d1049d3f676d53cfa93589b4a9b5c8f4b482a9a447d5f4afded50517ad176cf4 model_dir/poc_hash_external.onnx
6519070ba079418a50ef1e664e2407cd6d2cca143e864dc1b6ba1ed62cb30640 outside_dir/marker.bin
Applications that load an ONNX model without external data and then call public helper APIs with base_dir=os.path.dirname(model_path) can accidentally pass base_dir="" for relative filenames in the current working directory. In ONNX 1.21.0, the # external-data special case lets a parent symlink named #outside bypass the intended model-directory isolation in that helper path.
The PoC is benign and reads only a controlled marker file.
onnx.load(...) impact.base_dir="".# special case and a narrower helper API precondition.Treat base_dir="" as the model's actual containing directory rather than as a relative working-directory path, or reject empty base directories for external data. The # internal-memory-location special case should not skip containment and symlink validation for helper APIs that open external data from disk.