-
Notifications
You must be signed in to change notification settings - Fork 369
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
Is it safe to use System.Random to generate session tokens? #1725
Comments
That's probably a good call. Are you interested in sending such a pull request? |
I'd like to. However, I still have some confusion about session logic: If it is exposed to end user and used for authentication, it should be generated using a secure entropy source and has at least 128 bits (I would suggest using 256 bits for all kinds of secrets). |
Oh, I just realized this token is not session token. Yesod core does not have the "session token" concept. This is CSRF token and only used by |
I don't really remember the original design around CSRF tokens, and I'm not particularly interested in changing the way it works right now unless there's a concrete reason. Improving how they're generated for proper protection does still seem worthwhile though. |
yesod/yesod-core/src/Yesod/Core/Dispatch.hs
Line 96 in 5d8566a
yesod/yesod-core/src/Yesod/Core/Internal/Request.hs
Line 132 in 5d8566a
Yesod currently uses System.Random as the default random number generator, and uses this to generate session tokens. This looks very dangerous to me, because System.Random is only a pseudo-random number generator and has not been designed with security in mind. An attacker may easily collect enough information about the internal state of the generator and predict all future outputs.
I suggest using System.Entropy.
The text was updated successfully, but these errors were encountered: