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

Public key in JWT #44

Closed
bc-pi opened this issue Apr 9, 2024 · 9 comments · Fixed by #68
Closed

Public key in JWT #44

bc-pi opened this issue Apr 9, 2024 · 9 comments · Fixed by #68

Comments

@bc-pi
Copy link

bc-pi commented Apr 9, 2024

Please consider using the jwk header parameter to convey the public key in the JWT sent by the browser. That would better leverage existing standards, be similar to how DPoP did much the same thing: https://www.rfc-editor.org/rfc/rfc9449.html#name-dpop-proof-jwt-syntax, and remove ambiguity of "key": "public key", in the current example.

@arnar
Copy link
Collaborator

arnar commented Apr 10, 2024

Thanks. Just to check: The jwk header field is only meant to hold a key for which the JWT itself is signed with, correct?

That works fine here because the registration is self-signed, but if it ever wasn't (e.g. if we added cross-signing between sessions at some point) would it still make sense?

@bc-pi
Copy link
Author

bc-pi commented Apr 10, 2024

Thanks. Just to check: The jwk header field is only meant to hold a key for which the JWT itself is signed with, correct?

Yes. That's from https://www.rfc-editor.org/rfc/rfc7515#section-4.1.3

That works fine here because the registration is self-signed, but if it ever wasn't (e.g. if we added cross-signing between sessions at some point) would it still make sense?

It's hard to say in the abstract or hypothetical but wouldn't it make sense to figure out how that would work and define it when/if such a thing was added?

@sbweeden
Copy link
Contributor

Right now I captured a sample JWT from Chrome Canary:

eyJhbGciOiJFUzI1NiIsInR5cCI6Imp3dCJ9.eyJhdWQiOiJodHRwczovL2VsZmluLWNhcmFtZWwtZnJ1aXRhZGVucy5nbGl0Y2gubWUvaW50ZXJuYWwvU3RhcnRTZXNzaW9uIiwiaWF0IjoxNzE4MzM4MDA4LCJqdGkiOiJjaGFsbGVuZ2UiLCJrZXkiOnsiU3ViamVjdFB1YmxpY0tleUluZm8iOiJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVMWHhlVEdibjlIcW5rdlUtSlNkeEZ6ZFBXeWpSc0VJdTl1X1NiMUh3NkkwRUdxd25NQ2d2N2ZjY3ptUWxCbXVhOG9ueE1LMTBPOG1kajQxZVZXelJ4QSJ9fQ._eZ0B-f8cayEjntGOwag6OQBtHvj8T9KaDRg-Sb-hp-w0RsYmiaHbQi52582dhrbFtzx8kTsmrwEmo8XWS6RSA

Which has claims:

{
  "aud": "https://elfin-caramel-fruitadens.glitch.me/internal/StartSession",
  "iat": 1718338008,
  "jti": "challenge",
  "key": {
    "SubjectPublicKeyInfo": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELXxeTGbn9HqnkvU-JSdxFzdPWyjRsEIu9u_Sb1Hw6I0EGqwnMCgv7fcczmQlBmua8onxMK10O8mdj41eVWzRxA"
  }
}

This SubjectPublicKeyInfo is base64 asn1, and is difficult to parse. It would make more sense for this to be a JWK public key format as suggested.

@kmonsen
Copy link
Collaborator

kmonsen commented Jun 18, 2024

I'm looking into using JWK instead, should get some answer this week hopefully.

@bc-pi
Copy link
Author

bc-pi commented Aug 30, 2024

I maintain that the jwk header parameter would be more appropriate but this in #68 is an improvement nonetheless. Thank you.

@kmonsen
Copy link
Collaborator

kmonsen commented Aug 30, 2024

I maintain that the jwk header parameter would be more appropriate but this in #68 is an improvement nonetheless. Thank you.

How would you prefer it, like this?
Sec-Session-Response:
Sec-Session-Key:

@kmonsen kmonsen reopened this Aug 30, 2024
@arnar
Copy link
Collaborator

arnar commented Aug 30, 2024

Brian, is the implication of a jwk field in a JWT header that the JWT itself is necessarily signed by that key?

That happens to work in the most general case here where the registration message is self-signed, but it would preclude any form of deployment where the registration JWT is signed by a different key (this may be relevant to the enterprise-flavored proposal in #67).

If possible I'd like to leave that possibility open. The purpose of this public key is to save it on the server for verifying future refresh JWTs, more than it is for verifying the registration JWT itself.

(Sorry about the SubjectPublicKeyInfo bit left in there, it makes sense to use JWKs in the spec. We use SPKI formats for Google-specific deployments since we find it significantly safer and easier to parse than JWKs.)

@arnar
Copy link
Collaborator

arnar commented Aug 30, 2024

Sorry, I see I asked the same question back in April and you answered then already. We do want the ability to convey a public key in the registration JWT that is not the signing key of that JWT itself. That seems to violate the definition of the jwk header field.

@bc-pi
Copy link
Author

bc-pi commented Sep 6, 2024

My comment in #44 (comment) did mention a preference but wasn't meant to ask for this to be reopened, apologies for that. It was more intended to acknowledge and say thanks for the change to JWK formatting.

@arnar arnar closed this as completed Sep 6, 2024
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

Successfully merging a pull request may close this issue.

4 participants