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

[Question] How to correctly verify JWS for OIDC? #112

Open
stokito opened this issue Jan 13, 2022 · 0 comments
Open

[Question] How to correctly verify JWS for OIDC? #112

stokito opened this issue Jan 13, 2022 · 0 comments

Comments

@stokito
Copy link

stokito commented Jan 13, 2022

Thank you for your tool, it's amazing and code is very nice.
I developed a plain shell script that implements OAuth authorization for websites that are running on a small devices like router with OpenWRT.
Some OAuth OIDC providers like Google supports auth by id_token that is a JWS. And I need to verify it's signature with Google's JWKS fetched from https://www.googleapis.com/oauth2/v3/certs.

Currently this implemented by using openssl dgst -sha256 -verify command. The problem is that it needs for a public key in an old PEM format. Likely Google provides them at https://www.googleapis.com/oauth2/v1/certs

Now I would like to make it to verify with any JWKS. And likely found your tool.
I got the FB JWKS from https://www.facebook.com/.well-known/oauth/openid/jwks/. The JWKS file has two public keys.
Then I executed jose signature verification for the id_token received from FB:

 jose jws ver -i id_token.txt -k fb.jwks.json

It works, great.

But the problem is that keys in JWKS are rotated and changed after some time.
So I just changed the kid in the JWKS and now it's not the same as was used to issue the id_token. The verification was again successful.
So it looks like jose verified the id_token signature against both public keys and it now even care about the kid field in the id_token.
This still looks secure but maybe for a better performance jose can verify signature only against one public key from the JWKS.

Another problem is that if the JWKS file is outdated then signature verification will be failed because the id_token was signed with a newer public key.
So it would be great if jose can return a different exit code if the kid of id_token wasn't found in the JWKS.
Then my script can see that it needs to download an updated JWKS and re-run the verification.

Also from what I see the id_token expiration exp is not checked and outdated tokens are still verified. This is looks like something that is not related to the jose sig verification itself but anyway users may miss to do this.

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

1 participant