Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical JSON may not be valid JSON #92

Open
daurnimator opened this issue Feb 26, 2020 · 4 comments
Open

Canonical JSON may not be valid JSON #92

daurnimator opened this issue Feb 26, 2020 · 4 comments

Comments

@daurnimator
Copy link

daurnimator commented Feb 26, 2020

All documents use a subset of the JSON object format, with floating-point numbers omitted. When calculating the digest of an object, we use the "canonical JSON" subdialect as described at http://wiki.laptop.org/go/Canonical_JSON

Canonical JSON may be invalid JSON: canonical json says that control characters must not be escaped:

Because only two byte values are escaped, be aware that JSON-encoded data may contain embedded control characters and nulls.

Whereas JSON mandates that control characters are escaped.

I think this deserves a note in the specification, as normal json encoders and decoders cannot be used.

@joshuagl
Copy link
Member

joshuagl commented Mar 4, 2020

There are several related issues and discussions on Canonical JSON, i.e.
secure-systems-lab/securesystemslib#159 and theupdateframework/python-tuf#457

@erickt
Copy link
Contributor

erickt commented Mar 26, 2020

I recently learned of another attempt at a canonicalization scheme in the draft IETF spec rundgren-json-canonicalization-scheme. It doesn't have the same issue where strings may contain invalid JSON characters. It's probably a drop-in replacement for most TUF implementations, which I think don't actually allow for invalid JSON characters.

@lukpueh
Copy link
Member

lukpueh commented Mar 30, 2020

FYI: This topic has been added to the agenda for the next TUF community meeting. (date TBD, invitations will go to [email protected]).

@trishankatdatadog
Copy link
Member

trishankatdatadog commented Mar 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants