ZERO-UPLOAD SANDBOX
.onnx Tier 2 · Annotated Hex

ONNX (Open Neural Network Exchange)

Cross-framework Protocol Buffers computation graph and weight format used by ONNX Runtime, TensorRT, and CoreML converters.

Encoded as a Protobuf v2/v3 ModelProto message. Field 1 (ir_version) is typically serialized first as tag 0x08 followed by a varint IR version (e.g., 7..10).

MIME Types application/onnx, application/octet-stream
Byte Endianness little
0xFF

Drop any .onnx file (even 100 GB+) to inspect locally

Reads tiny File.slice() header/footer pages in a sandboxed Web Worker · 0 Bytes Uploaded

Binary Signature & Wire Layout

.onnx Magic Bytes & Header Offset Map

Offset: 0x00 (0 B)
08

Protobuf field #1 (ir_version) varint wire tag

Byte Offset Length Data Type Field Name Engineering Description
0x00 1 B uint8 ir_version_tag Protobuf tag 0x08 (field 1, varint)
0x01 1-2 B varint ir_version ONNX IR specification version
0x02+ var protobuf producer_and_graph Producer name, opset_import, and GraphProto
Upload Gateway & AppSec Advisory

.onnx Security & Polyglot Risk Matrix

Risk Level: medium
Arbitrary Code / Macros
NO (Inert Data)
Pickle Deserialization
SAFE (No Pickle VM)
XML External Entity (XXE)
NONE
Polyglot Prepend Risk
LOW (Strict 0x00 Magic)
Backend Upload Validation Recommendation

Audit external_data tensor file paths inside TensorProto to block arbitrary local file read (LFI / path traversal) when loading untrusted ONNX models.

Compiler-Verified Reference Code

Read .onnx Header & Metadata Without Heavy Dependencies

import sys
with open(sys.argv[1], "rb") as f:
    b = f.read(32)
    assert b[0] == 0x08, "Expected ModelProto.ir_version tag 0x08"
    print(f"ONNX ModelProto IR version={b[1]}")
CI/CD & Unit Test Fixtures

Deterministic .onnx Sample Files & Edge Cases

Open Full .onnx Sample Matrix & Mutator →
minimalexpect: valid

minimal-linear.onnx

Real ONNX ModelProto (ir_version=9, opset=21) verified by onnx.checker.check_model — MatMul + Relu.

↓ Download (319 B)
SHA-256: aa4e82d69b4579c1a7bfbf12228776f121238825abb64a45e937d4e1299a33fb
Exact: 319 bytes
curl -fsSL https://fileformat.co/fixtures/v1/onnx/minimal-linear.onnx -o minimal-linear.onnx \
  && echo "aa4e82d69b4579c1a7bfbf12228776f121238825abb64a45e937d4e1299a33fb  minimal-linear.onnx" | shasum -a 256 -c
realisticexpect: valid

mlp-classifier.onnx

onnx.helper-built MLP with float32 TensorProto initializers, Gelu activation — passes onnx.checker.

↓ Download (702 B)
SHA-256: bc52092748c786119aa203b36f61a706a5f40a426b9626ed0469552d9566ff4e
Exact: 702 bytes
curl -fsSL https://fileformat.co/fixtures/v1/onnx/mlp-classifier.onnx -o mlp-classifier.onnx \
  && echo "bc52092748c786119aa203b36f61a706a5f40a426b9626ed0469552d9566ff4e  mlp-classifier.onnx" | shasum -a 256 -c
edge-caseTruncated Protobuf Frameexpect: parser_error

truncated-protobuf.onnx

ModelProto wire frame truncated mid-GraphProto — ModelProto.ParseFromString must raise DecodeError.

↓ Download (56 B)
SHA-256: d4db86720670b6fb423cba89dae6fd0d3dc7a92624f836148e6fc29a590b06f4
Exact: 56 bytes
curl -fsSL https://fileformat.co/fixtures/v1/onnx/truncated-protobuf.onnx -o truncated-protobuf.onnx \
  && echo "d4db86720670b6fb423cba89dae6fd0d3dc7a92624f836148e6fc29a590b06f4  truncated-protobuf.onnx" | shasum -a 256 -c

Related Specifications & Alternatives