-
Notifications
You must be signed in to change notification settings - Fork 672
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
Fix EC token signature verification, add verify against JWKS URL, and more #60
base: master
Are you sure you want to change the base?
Conversation
Yearly ping @ticarpi. EC token sigs are still broken, care to review? |
Retested with RSA tokens, too. |
Bump @ticarpi, any review comment? |
I find so annoying that an effort for the community has been ignored for so long. Just wanted to say that and express my sympathy |
The correct variable name is `sig`, but under try: it's referred to as `signature`. Normally that'd crash with NameError exception -- but here we have a catch-all except block misinterpreting that as wrong signature.
Keys can be/are of wildly different types, including different elliptic curves. IETF RFC7518 (JWA) section 3.4 table mandates this 3-row map: | JWT.alg | Hash, curve | ES256 | SHA256, P-256 | ES384 | SHA384, P-384 | ES512 | SHA512, P-521 The assert (unless disabled with -O) will clearly fail when JWT mismatches the pubkey, (as far as by curve choice).
For those JWK's which lack the kid attribute, the logic assigns one. When parsing pubkey bundle (JWKS, a set of JWK), the previous logic enables a clash, consider this JWK sequence: * {"kid": "2", "kty":"EC", "use":"sig", ... } * {"kty":"RS", "use":"sig", ... } -- this saves with kid=1 * {"kty":"RS", "use":"enc", ... } -- this *overwrites* kid=2
Thanks @halfluke for the kind words 🙏 What's most annoying to me, is that other PRs #101 #108 do get reviewed & merged, and releases come out every so often. But radio silence here, no feedback whatsoever. Ping @ticarpi @rbrown256 @JJK96 anything I should change to land this fix?.. FWIW, rebased once again to resolve the merge confict. |
This looks like a worthwhile merge to me. Thanks for your contribution. @ticarpi any chance of merging this in? |
Greetings @ticarpi !
I'm unshelving a bunch of fixes to the tool, please consider merging.
Most important first:
I'm sure you know, there are Elliptic Curve based JWT algos, EC256 EC384 EC521. They were not getting sig-verified correctly. The bug may be hard to see in the diff, but it's pretty simple, I'll just echo the commit message:
With this fix, I got complete parity with https://jwt.io & other implementations.
I also added a straightforward "verify token against JWKS URL" mode, for UX speed reasons.
Some more bits and pieces too, I hope the rest will be obvious.
I tested the changes with real keys and tokens, mostly EC ones.
Feel free to question anything unclear in review; I'm hoping to get the PR landed, completely in the spirit of FOSS to make the tool ever a bit sharper 🚀
Best regards