Fix heap-buffer-overflow in minireflect.h during union vector parsing#9124
Fix heap-buffer-overflow in minireflect.h during union vector parsing#9124mabrukhany-beep wants to merge 4 commits into
Conversation
Add bounds check before reading union type tag from vector to prevent heap-buffer-overflow when union data vector size exceeds type vector size.
Register the new minireflect_fuzzer target and its seed corpus in the fuzzer CMake configuration.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@google-cla I signed it! |
|
Hi @dbaileychess, I’m following up on this PR which addresses a Heap OOB Read vulnerability I reported via the Google VRP (Issue 519835122). While the general project stance is to trust buffers after verification, this patch is critical for several reasons: 1 Inconsistent Vector State:** The root cause is a logic flaw in I’ve provided a Thanks! |
Summary
Fixes a heap-buffer-overflow in
IterateValue()when processing union vectorswhere the data vector size is desynchronized from the type tag vector size.
Bug Description
In
minireflect.h, theST_UNIONbranch reads the union type tag using:union_type = type_vec->Get(static_cast<uoffset_t>(vector_index));
The vector_index comes from a loop bounded by vec->size() of the data
vector, but type_vec points to the type tag vector — a separate vector
that may have a smaller size. When the buffer is malformed (e.g., data vector
size inflated), this causes an out-of-bounds read.
Fix
Added bounds check before type_vec->Get():
cpp
if (type_vec && static_cast<size_t>(vector_index) < type_vec->size()) {
union_type = type_vec->Get(static_cast<uoffset_t>(vector_index));
} else {
visitor->Unknown(val);
break;
}
Testing
Added minireflect_fuzzer libFuzzer harness
Added seed_minireflect/ directory for corpus
The fuzzer exercises FlatBufferToString() with the Movie schema which
contains union vectors
Related
This addresses a security issue where FlatBufferToString() can crash on
malformed buffers due to missing bounds checking in the mini-reflection
union vector path.