question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does JSON allowing duplicate keys affect TUF security?

See original GitHub issue

Although 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rbtcollinscommented, Jan 29, 2020

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.

0reactions
jkucommented, Feb 17, 2022

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found