Repository navigation
Fix 64-bit vector length arithmetic overflow in C++ verifier - #9422
Open
elnadym165 wants to merge 1 commit into
Open
elnadym165 wants to merge 1 commit into
elnadym165 wants to merge 1 commit into
Conversation
Account for the serialized length prefix when validating vector sizes against size_t limits. Add generated-schema regression coverage for default, 64-bit, and maximum size configurations.
elnadym165
force-pushed
the
security/verifier-vector-length-hardening
branch
from
October 20, 2026 12:38
598cf32 to
a593c0e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Harden the C++ verifier against overflow when calculating the serialized size of a vector with a 64-bit length prefix.
VerifierTemplate::VerifyVectorOrString()currently checks the element count againstmax_size / elem_size, then calculates:The element-count check does not account for the serialized length prefix. With an explicitly configured
max_sizesufficiently close toSIZE_MAX, a forged 64-bit element count can cause the addition to wrap, allowing a malformed vector to pass verification.Fix
Calculate the maximum safely representable element count after reserving space for
sizeof(LenT), and reject larger counts before computingbyte_size.The existing configured element-count limit is preserved.
Regression coverage
Add a test using the existing generated
RootTable.big_vectorschema. The test checks:SIZE_MAXverifier configuration.VerifierandSizeVerifier.The regression is executed from the existing 64-bit C++ test suite.
Validation
flattestsC++ test suite passed.flattestsC++ test suite passed with AddressSanitizer and UndefinedBehaviorSanitizer.Security and configuration notes
The demonstrated malformed input requires an unusually high, explicitly configured verifier
max_sizenearSIZE_MAX. The default verifier configuration and documented 64-bit maximum reject the tested input.Under the affected configuration, a malformed vector can pass generated-schema verification and a later accessor read can go out of bounds. No remote exploit or affected deployed application is claimed.
This contribution was coordinated with the Google Bug Hunter Team, which authorized submission as a standard upstream pull request.