Views
No views yet
onnx/checker.cc (Lines 129-132)1int64_t nelem = 1;
2for (auto x : tensor.dims()) {
3 nelem *= x; // NO OVERFLOW CHECK
4}1# Attacker crafts malicious .onnx file:
2malicious_dims = [4611686018427387904, 8] # 2^62 * 8 = 2^65
3
4# Victim loads model:
5import onnx
6model = onnx.load("malicious_model.onnx") # Automatic exploitation!
7
8# Result: INT64 overflow → Wrong heap size → Buffer overflow → RCEcheck_tensor() function in checker.cc multiplies tensor dimensions without checking for overflow:[2^62, 8] are multiplied: 2^62 * 8 = 2^65INT64_MAX (2^63-1)memcpy operationsVULNERABILITY CONFIRMED
Status: EXPLOITABLE
Impact: Heap Buffer Overflow
Primitive: Arbitrary Code Execution
Attack Complexity: LOW
User Interaction: NONECVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:Honnx.load())python3 exploit.pychecker.cc:1#include <limits>
2
3int64_t nelem = 1;
4for (auto x : tensor.dims()) {
5 // Check for negative dimensions
6 if (x < 0) {
7 fail_check("Negative dimension not allowed");
8 }
9
10 // Check for overflow BEFORE multiplication
11 if (x > 0 && nelem > std::numeric_limits<int64_t>::max() / x) {
12 fail_check("Dimension overflow detected");
13 }
14
15 nelem *= x;
16}
17
18// Add maximum tensor size limit
19const int64_t MAX_TENSOR_SIZE = 1LL << 40; // 1 TB
20if (nelem > MAX_TENSOR_SIZE) {
21 fail_check("Tensor size exceeds maximum allowed");
22}exploit.py - Verified proof-of-concept demonstrating exploitationREADME.md - This file