Repository navigation
Conversation
|
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. |
…used With a reuse tracker, VerifyVector marked a vector as verified before checking its elements. An element that referred back to the vector was accepted, so a cyclic vector verified and recursive consumers (Reference::ToString, used by flatc --json --flexbuffers) overflowed the stack. Mark the vector as in progress while its elements are checked, and fail if an in-progress vector is reached again. Shared, non-cyclic vectors still short-circuit as before.
vivek7424
force-pushed
the
fix-flexbuffers-cycle-reuse-tracker
branch
from
October 28, 2026 02:39
46e0b7b to
57dbe30
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
With a reuse tracker,
flexbuffers::VerifyBuffermarks a vector as verified before it checks that vector's elements. An element that refers back to the vector finds the mark and is accepted, so a cyclic vector verifies. A consumer that walks the data recursively, such asReference::ToString(used byflatc --json --flexbuffers), then recurses without bound and overflows the stack.This PR marks the vector as in progress while its elements are checked. An element that reaches an in-progress vector fails verification. Shared, non-cyclic vectors still short-circuit as before.
Reproduction
The 31-byte input from #9074:
Before this change:
VerifyBufferwith a reuse tracker returns true. Walking the first element reaches depth 300 on a 31-byte buffer, which is only possible through a cycle.VerifyBufferwithout a tracker returns false.flatc --json --flexbufferson this file segfaults, withToStringandAppendToString<Vector>repeating in the backtrace.After this change, all three reject the input.
Tests
FlexBuffersCycleRejectedTestchecks that these bytes fail to verify with and without a tracker. The unpatched tree fails this test atflexbuffers_test.cpp:330. With this change, the fullflattestssuite passes.Notes