Repository navigation
Check json_validate() in the JSON fuzzer - #24723
Open
yumasansansan wants to merge 2 commits into
Open
yumasansansan wants to merge 2 commits into
yumasansansan wants to merge 2 commits into
Conversation
The fuzzer used a depth of 10 rather than json_decode()'s default of 512, so every input nesting deeper than that failed early. json_validate() uses its own parser methods and was not fuzzed at all. Check that it agrees with decoding to arrays, which, unlike decoding to objects, does not reject property names starting with a NUL byte.
Member
|
Some possibilities for the lower limit:
|
Contributor
Author
|
Good points, I measured it. Time per input for the same input run 3000 times (ASan build):
On the checked-in corpus, the higher depth only adds 5 edges (1252 → 1257), while |
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.
json_validate()(php_json_validate_ex()) runs the same scanner and grammar asjson_decode()with a separate set of parser methods that build no values, and was not covered by any fuzzer. ForJSON_OBJECT_AS_ARRAY(with and withoutJSON_INVALID_UTF8_IGNORE), decoding fails exactly when validation fails, apart from running out of memory, which cannot happen in this fuzzer. Decoding to objects is excluded, as it additionally rejects property names starting with a NUL byte. The fuzzer now asserts that both agree.The fuzzer keeps its depth of 10, which is lower than the default of 512, so that deeply nested inputs fail quickly and the depth limit is reached with small inputs. This is now documented in a comment.
Replaying the checked-in
sapi/fuzzer/corpus/json(no fuzzing): edge coverage 1211 → 1252, and the assertion holds for every seed. The input format is unchanged.