Skip to content

[C++] Vector of unions verifier does not check type vector length #8567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Muon opened this issue Mar 31, 2025 · 0 comments
Open

[C++] Vector of unions verifier does not check type vector length #8567

Muon opened this issue Mar 31, 2025 · 0 comments

Comments

@Muon
Copy link

Muon commented Mar 31, 2025

The length of the type vector is not checked when verifying a vector of unions. Instead, the code assumes that it is as long as the value vector:

auto type_vec = table.GetPointer<Vector<uint8_t> *>(vec_field.offset() -
sizeof(voffset_t));
if (!v.VerifyVector(type_vec)) return false;
for (uoffset_t j = 0; j < vec->size(); j++) {
// get union type from the prev field
auto utype = type_vec->Get(j);
auto elem = vec->Get(j);
if (!VerifyUnion(v, schema, utype, elem, vec_field)) return false;
}

If the code is not compiled with NDEBUG, the out-of-bounds access will be caught by the assert in Get(). However, this is a potential security problem for release builds operating on untrusted flatbuffers.

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

No branches or pull requests

1 participant