fix: harden MiniReflect union handling for NONE and unknown union types#9126
Open
Adyej999 wants to merge 1 commit into
Open
fix: harden MiniReflect union handling for NONE and unknown union types#9126Adyej999 wants to merge 1 commit into
Adyej999 wants to merge 1 commit into
Conversation
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.
Problem
MiniReflect resolves union value offsets before fully confirming that the union discriminator represents a concrete union member.
For
NONEand unknown/future union discriminator values, MiniReflect should avoid treating the union value as a concrete object. These cases can occur when inspecting unusual, malformed, or fuzzed FlatBuffer inputs through MiniReflect APIs such as:The affected code path is in:
Impact
MiniReflect is used for FlatBuffer inspection and stringification. If union traversal is not defensive for non-concrete union states, MiniReflect can attempt invalid type-reference or value-offset handling while walking the buffer.
This makes MiniReflect less robust for edge-case union states and fuzzed inputs, especially for:
Fix
This PR hardens MiniReflect union traversal so that union value offsets are not resolved before the union discriminator is known to represent a concrete union member.
The change:
Additional coverage
This PR also adds regression coverage for:
A new MiniReflect fuzzer target is also added:
The fuzzer exercises MiniReflect APIs such as
FlatBufferToString()andIterateFlatBuffer()over normal and size-prefixed inputs, includingNONEand unknown/future union states.Verification
Tested locally with: