{{ message }}
Fix vulnerability in JSON parsing#9491
Merged
Merged
Conversation
thiagoftsm
approved these changes
Jul 6, 2020
thiagoftsm
left a comment
Contributor
There was a problem hiding this comment.
The changes are removing any possibility of buffer overflow when this function is called. LGTM!
stelfrag
approved these changes
Jul 7, 2020
stormi
added a commit
to xcp-ng-rpms/netdata
that referenced
this pull request
Jul 16, 2020
stormi
added a commit
to xcp-ng-rpms/netdata
that referenced
this pull request
Jul 16, 2020
stormi
added a commit
to xcp-ng-rpms/netdata
that referenced
this pull request
Jul 16, 2020
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
If JSON-C is used function:
will use
memcpywithout checking length is less than256. ReasonJSON_NAME_LENis defined as256:By parsing JSON with a key name longer than 256 characters I am able to overwrite memory after with honorable mention being the address of
callback_functionlater in the same struct!By sending such a JSON trough ACLK I was able to verify that such a key will be parsed by
JSON-Cand arrive at this function withsize_t length = strlen(key);returning 4096! (which is key name length in my crafted JSON dictionary)Sample from debugger:

Component Name
Agent JSON switch (code that allows to use of internal JSON and JSON-C parser)
Test Plan
Parsing JSON with key with a name longer than 256 should not create buffer overflow. Example send custom JSON over ACLK link with such key.
Additional Information