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

User.find_by(token: token) is vulnerable to Timing attacks #11

Closed
yuki24 opened this issue Feb 24, 2017 · 2 comments
Closed

User.find_by(token: token) is vulnerable to Timing attacks #11

yuki24 opened this issue Feb 24, 2017 · 2 comments

Comments

@yuki24
Copy link
Contributor

yuki24 commented Feb 24, 2017

user = User.find_by(token: token)

This is in fact insecure and shouldn't be encouraged.

@yuki24 yuki24 changed the title user = User.find_by(token: token) is vulnerable to Timing attack user = User.find_by(token: token) is vulnerable to Timing attacks Feb 24, 2017
@yuki24 yuki24 changed the title user = User.find_by(token: token) is vulnerable to Timing attacks User.find_by(token: token) is vulnerable to Timing attacks Feb 24, 2017
@yuki24 yuki24 changed the title User.find_by(token: token) is vulnerable to Timing attacks User.find_by(token: token) is vulnerable to Timing attacks Feb 24, 2017
@vasilakisfil
Copy link
Owner

I thought that was possible only on LAN networks but probably you are right we should make it more secure. 2 ways I am thinking:

  • requiring the client to send the email as well so that we can first find the user based on the email and then do the secure compare on the token
  • returning a JWT to the client that is encrypts both the token and the email and do the same as above but client has only 1 thing to send.

I think I like the second option better so I will rewrite the section tomorrow.

@vasilakisfil
Copy link
Owner

fixed by #19
Eventually went for regular token/email authentication that I also had in the previous tutorial (first find user by email, then check the token using ActiveSupport::SecurityUtils.secure_compare). Feels like JWT tokens are for more special use cases.

Thank you!

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

2 participants