Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake algorithm option required to verify signature #184
Conversation
If the algorithm is not provided and the one in the token's header is used instead, we might be vulnerable to the attack explained here: https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/ For ex: A server expecting an RSA signed token would do this: `JWT.decode(token, rsa_public)` So an attacker can potentially sign a token with HS256 using the same RSA public key (which is publicly available), and the server will think it's valid. `JWT.encode({ user: 1 }, rsa_public, 'HS256')` This doesn't seem to be exploitable right now because the current implementation of OpenSSL::HMAC.digest expects a string as the key, so if rsa_public is an OpenSSL::PKey::RSA object, JWT.decode will raise an error. But it would be better not to depend on this OpenSSL::HMAC.digest behavior
Thanks for fixing this security issue. |
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information.
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information. I've created a PR on signet to. That has to be merged before ruby-jwt 2.0 can be really used (see googleapis/signet#93). Tested locally against ruby-jwt 2.0 and 1.5.6.
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information. I've created a PR on signet to. That has to be merged before ruby-jwt 2.0 can be really used (see googleapis/signet#93). Tested locally against ruby-jwt 2.0 and 1.5.6.
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information. I've created a PR on signet to. That has to be merged before ruby-jwt 2.0 can be really used (see googleapis/signet#93). Tested locally against ruby-jwt 2.0 and 1.5.6.
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information.
* Support ruby-jwt 2.0 This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information. * Use specific version of JRuby to fix CI for now
This version of ruby-jwt requires specification of the algorithm (see jwt/ruby-jwt#184) for more information. I've created a PR on signet to. That has to be merged before ruby-jwt 2.0 can be really used (see googleapis/signet#93). Tested locally against ruby-jwt 2.0 and 1.5.6.
EmilioCristalli commentedJan 17, 2017
Looks like this was discussed before in #107, which was closed with a README update specifying the algorithm was required, but it doesn't seem like the code is actually requiring it.
If the algorithm is not provided and the one in the token's header is used
instead, we might be vulnerable to the attack explained here:
https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/
For ex:
A server expecting an RSA signed token would do this:
JWT.decode(token, rsa_public)
So an attacker can potentially sign a token with HS256 using the same RSA public
key (which is publicly available), and the server will think it's valid.
JWT.encode({ user: 1 }, rsa_public, 'HS256')
This doesn't seem to be exploitable right now because the current implementation
of OpenSSL::HMAC.digest expects a string as the key, so if rsa_public is an
OpenSSL::PKey::RSA object, JWT.decode will raise an error. But it would be
better not to depend on this OpenSSL::HMAC.digest behavior