Fix Stack Overflow DoS via Unbounded Recursion in idl_gen_text.cpp#9037
Open
YLChen-007 wants to merge 1 commit intogoogle:masterfrom
Open
Fix Stack Overflow DoS via Unbounded Recursion in idl_gen_text.cpp#9037YLChen-007 wants to merge 1 commit intogoogle:masterfrom
YLChen-007 wants to merge 1 commit intogoogle:masterfrom
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. |
08f1cf3 to
3a8d697
Compare
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.
Fix Stack Overflow DoS via Unbounded Recursion in idl_gen_text.cpp
Description
A Denial of Service (DoS) vulnerability exists in the
flatccompiler when converting binary FlatBuffers to text/JSON format. A missing recursion depth guard inidl_gen_text.cppallows a maliciously crafted, deeply nested binary FlatBuffer (e.g., via a self-referencing table) to cause unbounded recursion between theGenStructandPrintOffsetfunctions. Processing such a file exhausts the process stack, resulting in an immediate segmentation fault (SIGSEGV).This PR adds a
depth_limitcheck toJsonPrinter(matchingFLATBUFFERS_MAX_PARSING_DEPTH), guarded via aDepthGuardscope manager, to safely catch arbitrarily nested inputs and return a text generation error instead of exhausting the C++ call stack.Testing
Compiled
flatcand successfully tested against anevil.bin(depth > 20,000) generated targeting an explicitly recursive schema (table Node { child: Node; }).Without the patch:
./flatc --raw-binary -t nest.fbs -- evil.bin-> Segmentation faultWith the patch:
./flatc --raw-binary -t nest.fbs -- evil.bin-> error: Unable to generate text for evil (error: text generation depth limit exceeded)