Skip to content

Fix OOB buffer index in GetFlatbufferTensorBuffer - #3648

Open
cloudymonstera wants to merge 1 commit into
tensorflow:mainfrom
cloudymonstera:fix/buffer-index-bounds-getflatbuffertensorbuffer
Open

Fix OOB buffer index in GetFlatbufferTensorBuffer#3648
cloudymonstera wants to merge 1 commit into
tensorflow:mainfrom
cloudymonstera:fix/buffer-index-bounds-getflatbuffertensorbuffer

Conversation

@cloudymonstera

Copy link
Copy Markdown

Summary

  • Add a bounds check on attacker-controlled tensor.buffer() before indexing the model buffers vector in GetFlatbufferTensorBuffer.
  • Mirrors the existing guard used by the compression-metadata path in the same file (buffer_index >= buffers->size()).
  • Prevents out-of-bounds reads via flatbuffers::Vector::operator[] during MicroInterpreter::AllocateTensors() when loading a crafted .tflite.

Test plan

  • Existing TFLM unit / integration tests still pass
  • Crafted model with buffers.size()==2 and tensor.buffer()==65535 no longer reaches an OOB index (returns null buffer / fails allocation cleanly instead of reading past the vector)
  • Valid models with in-range tensor.buffer() indices still allocate and invoke successfully

Made with Cursor

Reject tensor.buffer() values that are out of range for the model
buffers vector before indexing, matching the existing check used by the
compression-metadata path in the same file.

Without this guard, a crafted .tflite can cause an out-of-bounds read
via flatbuffers::Vector::operator[] during AllocateTensors().
@cloudymonstera
cloudymonstera requested a review from a team as a code owner August 3, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant