-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
avoid key mixup for JWT access token validation #196
Comments
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
This discussion sounds familiar #122 (comment) :-) Back then we didn't see a big difference and kept what looked like the smaller change. No problem with making the difference explicit for opts as well but this probably cannot be done in a backwards compatible way. |
@bodewig can you confirm that the new log message shows up in your unit tests? Strangely I don't seem to be able to see it. https://github.com/zmartzone/lua-resty-openidc/compare/avoid-key-confusion |
Yes, I see it.
It is a bit tricky, I've removed all tests except for "when using a statically configured RSA public key" from I'll look into adding an assertion and a new test case that verifies the warning is not there when using the new keys and push it to the branch. |
Signed-off-by: Stefan Bodewig <stefan.bodewig@innoq.com>
see a71f2d1 |
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
Signed-off-by: Stefan Bodewig <stefan.bodewig@innoq.com>
As someone pointed out to me,
lua-resty-openidc
in its default setup seems vulnerable to https://www.chosenplaintext.ca/2015/03/31/jwt-algorithm-confusion.htmlIt appears one can create a symmetric key "derived" from a public RSA key and use that "crafted" symmetric key to sign a JWT with alg
HS256
and present that token toopenidc_load_jwt_and_verify_crypto(opts, access_token, opts.secret, opts.secret, opts.token_signing_alg_values_expected, …)
at: https://github.com/zmartzone/lua-resty-openidc/blob/v1.6.1/lib/resty/openidc.lua#L1435This would validate the HS256 access token because it would treat the public key stored in
opt.secret
as a symmetric key value.This is only possible when
opts.token_signing_alg_values_expected
is not set so an attacker can confuse the validation function. Since this option is not set by default, lua-resty-openidc is vulnerable by default to the attack described above and we can do better.Note that this won't work for the
id_token
in an OIDC RP setup as theid_token
is only returned from backchannel call to a trusted OP.I believe we should split the
opts.secret
configuration option into an explicitopts.symmetric_key
andopts.public_key
value, probably providing some backwards compatibility with a warning.@bodewig what do you think?
The text was updated successfully, but these errors were encountered: