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

use canonical json form for signed responses #1112

Open
bhearsum opened this issue Dec 20, 2019 · 5 comments · Fixed by #3035
Open

use canonical json form for signed responses #1112

bhearsum opened this issue Dec 20, 2019 · 5 comments · Fixed by #3035
Labels
blobs release blob schemas/code first-bug good first bug public public Balrog app/api (aus5.mozilla.org; aus-api.mozilla.org)

Comments

@bhearsum
Copy link
Contributor

Currently, we don't have any guarantees that our JSON responses will be bit-for-bit the same for the same request. This means that any time the response format changes, we'll have to generate additional, possibly unnecessary, signatures (because we use the hashed, dumped-to-a-string, json as our cache key).

Something like https://github.com/Kinto/kinto-signer/blob/master/kinto_signer/canonicaljson.py or https://pypi.org/project/canonicaljson/.

Thanks to glasserc for the idea and pointers.

(Imported from https://bugzilla.mozilla.org/show_bug.cgi?id=1590609)

@bhearsum bhearsum added public public Balrog app/api (aus5.mozilla.org; aus-api.mozilla.org) blobs release blob schemas/code labels Dec 20, 2019
@bhearsum bhearsum added the first-bug good first bug label Jan 7, 2020
@Raven49
Copy link

Raven49 commented Oct 7, 2023

Kindly assign this task to me

@bhearsum
Copy link
Contributor Author

Hi, please feel free to work on the issue and open a PR when you feel it is ready.

@michellemounde
Copy link
Contributor

Could I have more info about this issue ? @bhearsum @gabrielBusta
Could you provide the file(s) where the changes should be made?

@bhearsum
Copy link
Contributor Author

This issue boils down to the fact that the JSON responses we return are not deterministic: it is possible that we may return exactly the same data but in a different order for different requests.

Fixing it requires ensuring the response object is built deterministically, probably by using one of the linked libraries.

@jcristau
Copy link
Contributor

Reopening because the fix in #3035 had to be reverted in #3058.

Changing json.dumps to canonicaljson.encode_canonical_json changed a text string to a byte string, which when passed to make_hash returns a bogus hash, and thus causes us to end up with a bogus signature.

@jcristau jcristau reopened this Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blobs release blob schemas/code first-bug good first bug public public Balrog app/api (aus5.mozilla.org; aus-api.mozilla.org)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants