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

Add algorithm hs2019 to createAuthzHeader. #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aljones15
Copy link
Contributor

@aljones15 aljones15 commented Oct 9, 2020

Adds hs2019 to the authz headers:

Signature keyId="did:key:z6Mkkhu5bsDV391yVtYgUEBpFa2D5eX68gnnChYZNZtaPvmf#z6Mkkhu5bsDV391yVtYgUEBpFa2D5eX68gnnChYZNZtaPvmf",algorithm="hs2019",headers="(key-id) (created) (expires) (request-target) host capability-invocation",signature="5r0pUbSekVMDVzSc4hIdwQmuDRm1KEsWkEA8EIsafOy7K9x+1wWbtTKdubkda1/eDB2qJjpgfZ9LNnAuNNu5Aw==",created="1602254205448",expires="1602254805448"

this also ensures the tests are using the latest http-signature-zcap-verify

Tests:

  • All unit tests pass
  • Have tried this in a branch of edv-client with no errors so far.

This corrects an error @msporny found here: https://github.com/decentralized-identity/secure-data-store/issues/113

@aljones15 aljones15 requested a review from msporny October 9, 2020 14:37
@aljones15 aljones15 self-assigned this Oct 9, 2020
@aljones15 aljones15 added the invalid This doesn't seem right label Oct 9, 2020
@aljones15 aljones15 marked this pull request as ready for review October 9, 2020 15:15
@msporny
Copy link
Member

msporny commented Oct 9, 2020

Great @aljones15, thank you!

I expect that we may also need to sign over the canonicalization value of "(canonicalization-algorithm) hs2019" -- but that's for later... we'll have to push that through the IETF HTTP WG.

Copy link
Member

@msporny msporny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The algorithm is unprotected, which probably needs to be fixed in a future PR.

Copy link
Member

@msporny msporny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... on second thought, why is this not going in the base http-signature library? That's where this belongs, right?

/cc @dlongley @davidlehn -- does "hs2019" go in the base http-signatures library?

@aljones15
Copy link
Contributor Author

Hmm... on second thought, why is this not going in the base http-signature library? That's where this belongs, right?

/cc @dlongley @davidlehn -- does "hs2019" go in the base http-signatures library?

@msporny I can't seem to find a latest version of the spec that makes algorithm required. The latest one I could find is the one that expires Oct 12 2020 and in that spec algorithm is recommended (it was required in a 2014 spec). Is there a newer spec I need to look at?

@aljones15
Copy link
Contributor Author

ok so sorry to harp on this one, but:

"algorithm"
RECOMMENDED. The "algorithm" parameter contains the name of the
signature's Algorithm, as registered in the HTTP Signature
Algorithms Registry defined by this document. Verifiers MUST
determine the signature's Algorithm from the "keyId" parameter
rather than from "algorithm". If "algorithm" is provided and
differs from or is incompatible with the algorithm or key material
identified by "keyId" (for example, "algorithm" has a value of
"rsa-sha256" but "keyId" identifies an EdDSA key), then
implementations MUST produce an error. Implementers should note
that previous versions of this specification determined the
signature's Algorithm using the "algorithm" parameter only, and
thus could be utilized by attackers to expose security
vulnerabilities. The default value for this parameter is
"hs2019".

https://tools.ietf.org/html/draft-ietf-httpbis-message-signatures-00#section-4.1

so it says it is RECOMMENDED, but has a default value?

@OR13
Copy link

OR13 commented Oct 23, 2020

@aljones15 yes, the spec is not super helpful here...

https://tools.ietf.org/html/draft-ietf-httpbis-message-signatures-00#section-5.1.2

recommended support for Ed25519 is the only part that is relevant IMO.

I would interpret the spec as follows:

use hs2019, throw if you encounter a key that is not Ed25519 for now.

@aljones15
Copy link
Contributor Author

@aljones15 yes, the spec is not super helpful here...

https://tools.ietf.org/html/draft-ietf-httpbis-message-signatures-00#section-5.1.2

recommended support for Ed25519 is the only part that is relevant IMO.

I would interpret the spec as follows:

use hs2019, throw if you encounter a key that is not Ed25519 for now.

that's basically how the binary works:

https://github.com/digitalbazaar/http-signature-header/blob/80f2648e8b850100e1620a4c340fc613040bbb65/bin/util.js#L31-L44

Copy link
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepting this because the createAuthzHeader used here is a helper function that does not do anything with the algorithm used. This allows other algorithms to be used in combination with different canonicalization mechanisms -- but this lib uses the only one provided by the underlying library at the moment -- and so hs2019 matches that usage.

@mattcollier
Copy link
Contributor

@aljones15 Please address merge conflicts and add a changelog entry at your convenience.

@aljones15
Copy link
Contributor Author

aljones15 commented Mar 10, 2021

@mattcollier this was intended to be part of the implementation of version 13 of the http sigs spec. However I guess this can be added as we are using hs2019 and adding it would probably help in the future if we decide to change algorithm. This is not a priority for me, but will be addressed in the future.

@aljones15 aljones15 force-pushed the add-algorithm-to-authz-header branch from dc05a12 to c229e11 Compare March 29, 2021 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants