The Wayback Machine - https://web.archive.org/web/20200906101607/https://github.com/jwt/ruby-jwt/pull/184/
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

Make algorithm option required to verify signature #184

Merged
merged 1 commit into from Feb 2, 2017

Conversation

@EmilioCristalli
Copy link
Contributor

EmilioCristalli commented Jan 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

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
@excpt excpt self-requested a review Jan 17, 2017
@excpt excpt self-assigned this Jan 17, 2017
@excpt excpt added the bug label Jan 17, 2017
@excpt excpt added this to the Version 1.6.0 milestone Jan 17, 2017
@excpt excpt removed the review required label Jan 18, 2017
@excpt
excpt approved these changes Feb 2, 2017
Copy link
Member

excpt left a comment

Thanks for fixing this security issue. 👍

@excpt excpt merged commit ffceff6 into jwt:master Feb 2, 2017
2 checks passed
2 checks passed
codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@EmilioCristalli EmilioCristalli deleted the EmilioCristalli:require-algorithm branch Feb 4, 2017
jurriaan added a commit to jurriaan/signet that referenced this pull request Sep 15, 2017
This version of ruby-jwt requires specification of the algorithm (see
jwt/ruby-jwt#184) for more information.
jurriaan added a commit to jurriaan/google-auth-library-ruby that referenced this pull request Sep 15, 2017
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.
jurriaan added a commit to jurriaan/google-auth-library-ruby that referenced this pull request Sep 15, 2017
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.
jurriaan added a commit to jurriaan/google-auth-library-ruby that referenced this pull request Sep 15, 2017
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.
jurriaan added a commit to jurriaan/signet that referenced this pull request Sep 18, 2017
This version of ruby-jwt requires specification of the algorithm (see
jwt/ruby-jwt#184) for more information.
dazuma added a commit to googleapis/signet that referenced this pull request Oct 4, 2017
* 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
oleksandrbyk added a commit to oleksandrbyk/olek-google-auth-library that referenced this pull request Mar 4, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.