Does JSON allowing duplicate keys affect TUF security?
See original GitHub issueAlthough we use objects/dictionaries/associate arrays in JSON to ensure that the TUF updater would not associate multiple values with the same key, note that this does not prevent duplicate keys from being transmitted in the JSON anyway. Furthermore, a JSON deserializer may not warn about duplicate keys. For example, in Python now:
>>> import json; d=json.loads('{"foo":"bar","foo":"baz"}'); print(d['foo'])
baz
I haven’t thought through whether this has security implications, but I wonder whether this may be worth considering.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Does JSON syntax allow duplicate keys in an object?
The short answer: Yes but is not recommended. The long answer: It depends on what you call valid... ECMA-404 "The JSON Data Interchange...
Read more >How do you handle duplicate keys in JSON?
Here, the valid duplicate keys in JSON is an exception and not a rule,but here we'll face the common problem when it comes...
Read more >Duplicate Keys in JSON - Forums - IBM Support
I've done some research and I understood that "duplicate" keys in JSON are legal, but different parsers act differently in handling this.
Read more >5 SQL/JSON Conditions IS JSON and IS NOT JSON
The JSON standard recommends that a JSON object not have duplicate field names. Oracle Database enforces this for JSON type data by raising...
Read more >Frequently asked questions - Azure Container Registry
Is there security vulnerability scanning for images in ACR? ... verify those public keys and certificates after the overall TUF verification ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree. I think it is a property of any serialization scheme where the behaviour of repeated keys in a hash is implementation defined. First-key, Last-key or multi-map can all be secure, but “implementors choose a strategy they prefer” much less so.
we could create our own
object_pairs_hook
to error/warn if we see duplicate keys in deserialization but I don’t think this will end up on top of my TODO list … and looks like this opinion is shared as nothing has happened here in six years.I think I’ll close this: If this was meant to be a specification issue instead of python-tuf issue, please file in https://github.com/theupdateframework/specification/issues (for the record, I think “last-key-wins” is the right choice as it tends to Just Work, but explicitly erroring out on duplicates would be doable as well)