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

JWT is easily breakable #267

Closed
gotoAndBliss opened this issue May 10, 2018 · 4 comments
Closed

JWT is easily breakable #267

gotoAndBliss opened this issue May 10, 2018 · 4 comments

Comments

@gotoAndBliss
Copy link

gotoAndBliss commented May 10, 2018

rsa_private = OpenSSL::PKey::RSA.generate 2048
rsa_public = rsa_private.public_key

token = JWT.encode payload, rsa_private, 'RS256'

decoded_token = JWT.decode token, rsa_public, true, { algorithm: 'RS256' }

Oh so fancy! RSA protected?

JWT.decode token, 'whatever_kind_of_string', false

Works for every single encryption value offered by JWT

Good luck guys!

@ab320012
Copy link
Contributor

The values are signed to prevent modifying not encrypted check out this article https://stackoverflow.com/questions/454048/what-is-the-difference-between-encrypting-and-signing-in-asymmetric-encryption

@dklotz
Copy link

dklotz commented May 29, 2018

@gotoAndBliss First of all you seem to be confusing signing and encryption. The JWT standard (not only this library) only does the former. The tokens themselves (header, payload and signature) are just Base64-encoded for transport, never encrypted (just e.g. paste any JWT into the box on jwt.io to see the plaintext). There is a second standard (JWE) that does encryption, but that is for different use cases and is not handled by this library AFAIK.

Secondly, in the second snippet you provided (... 'whatever_kind_of_string', false), you explicitly set the verify flag to false, so of course the signature is not verified. What else did you expect to happen in that snippet?

@SampsonCrowley
Copy link

Why is this even still open? signing != encrypting

@SampsonCrowley
Copy link

if you need encryption, use ruby-jwe and pass the JWT as the encryption payload

@excpt excpt closed this as completed Aug 3, 2018
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

5 participants