-
Notifications
You must be signed in to change notification settings - Fork 144
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
Discuss: Security concerns #30
Comments
Thanks for your feedback! I always like to make this project more secure, so every discussion around this is very welcomed. These are the security aspects:
IMHO this is pretty secure. If the attacker still gets the cookie and can decrypt it:
I am very interested what other folks have to say! |
@lipp, thanks for your work on this project! I have a (potentially naive) question about JWT encryption and thought it might be an appropriate part of this discussion. My understanding when you say the cookie (JWT) is encrypted is that without a decryption key, it is not possible to read the contents of the cookie. However, I am able to access the contents by Base64 decoding the middle part of the JWT. Reproduction stepsMy JWT (stored in the cookie) according to login-with If I copy the whole JWT into jwt.io's debugger, I immediately see my access token available in the payload section: Additionally, if I just copy the middle part of the JWT (the payload), I get the same result. My questionAssuming someone gets my JWT from the cookie, is there anything to stop them from using my access token to access the GitHub API? Is there a misunderstanding on my part between encoding and encryption? Thanks for your help :) |
@danthareja THX for investigating. This might be serious. I'll look into this ... |
after thinking about it... this is intentional 😄
Hope this makes things clearer. |
@lipp - thank you, this does indeed clear things up. |
@danthareja great! |
There is a nice strategy to prevent CSRF attacks called Double Submit Cookie. I think it works like this: login-with adds a random key to the payload of the JWT that it stores in the login-with creates another JWT and signs it with the random key from above. This token is stored in another cookie, which is Now in order to request a secure API endpoint the client JS application has send the token from the That means the API receives two tokens for each request, one over the HTTP headers from the JS client and one from the To validate the user the API decodes the first JWT (the one from the You can find more on this here: https://stackoverflow.com/a/37396572/1612318 login-with could provide an env var called I think this would be easy to implement (just the first two steps from above). The biggest challenge I see would be the documentation for something like this. ^^ |
I think it's unsafe to leave sensitive data such as access tokens (in the case of Oauth2 like Google).
If an attacker is able to retrieve a cookie he can easily decode the JWT token and use the access token to issue arbitrary requests to the authentication provider APIs and retrieve any information that might have been originally granted to it by the user (e.g. read my Gmail emails...).
I think the point of this lib is to make this kind of authentication processes stateless (or backendless) and storing the access tokens directly in the cookie is an easy win. Anyway I would at least try to protect this sensitive data by applying some level of encryption, maybe a simple symmetric encryption, using the same secret used to generate the JWT token signature as key would enough...
I look forward to knowing the community thoughts on this matter
The text was updated successfully, but these errors were encountered: