Repository navigation
parser json BUGFIX use-after-free of escaped member names - #2593
Merged
Merged
Conversation
A member name containing escape sequences is decoded into a buffer owned by the JSON context, which is freed by the next lyjson_ctx_next(). lydjson_meta_attr_instance() and lydjson_envelope() kept using the name/prefix pointing into it after that call, so take ownership of the buffer the same way lydjson_subtree_r() does.
Member
|
Um, yes, thanks, I will also fix the tests. But I have changed the base branch to |
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.
Repro: parse
{"a:foo":"xxx","@a:foo":{"a:hin\u0074":1}}with an ASan build, or runregress_fuzz_lyd_parse_mem_jsonon the existingpull1626corpus file; both report a heap-use-after-free (inly_strncmpfromlyd_get_meta_annotation, and indict_insertfromlyd_create_attr). A RESTCONF notification starting with{"ietf-restconf:notificatio\u006e":...}hits the same thing inlyd_create_opaqvialydjson_envelope().Cause: a member name with escapes is decoded into a buffer owned by the JSON context, and
lydjson_meta_attr_instance()/lydjson_envelope()keepname/prefixpointing into it across thelyjson_ctx_next()that frees it.Fix: take ownership with
lyjson_ctx_give_dynamic_value(), same aslydjson_subtree_r()already does for node names. Both cases are covered intest_parser_json.c; they abort under ASan without the fix, and the full ctest run (including the fuzz regression) passes with it.