-
Notifications
You must be signed in to change notification settings - Fork 258
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
Break the md5 hash #35
Conversation
Otherwise the md5 string can be decrypted and the application string is reveled. Which is a security concern.
or don't use the app.key. Either way. |
Probably safest not to use the app.key at all. We really just need a random string here. Could be something like:
which produces a 32-character token like |
agreed, there would need to be a check that the generated code is unique |
I got your points but What do you guys think? |
You don't need to know the app key, once you undo the md5 you can clearly see the microtime and app.key. MD5 is not a secure encryption mechanism. http://www.md5.net/encryption.php I'd say we should use hash('sha256',microtime().static::$app['config']->get('app.key')) |
I strongly feel that the app's key should not be used here at all, even if it's hashed with something more secure than md5. It's just not necessary to use it as the seed. The app key is meant to be kept private since it's used by Laravel as the key for unencrypting data if you ever use Laravel's Crypt functions. So sending it out in an email to new users, even in hashed form, isn't secure because then we're relying on the security of the hash function when we don't even need to do that. We can just not use it as the seed. All we need is a unique, unguessable string, right? A UUIDv4 would work perfectly. (v4 is the random UUID) Microtime isn't considered unique because theoretically it could be called twice at the same time on a machine or across multiple machines. That's why uniqid() (which is based off microtime) blocks for 1 microsecond to ensure uniqueness if it's not called with the true flag set for more entropy (which is why I used the true flag). But even then you have only ensured uniqueness on that machine. If you have more than one web server, the PHP manual recommends prefixing with the machine name to guarantee uniqueness across multiple machines. Since we can't know Confide users' machine names or that they're unique, I added mt_rand as the prefix for this. At that point you can be certain it's unique on any given machine and pretty darn certain that it's also unique across multiple machines. And it's unguessable because of the random prefix, it's not just time based. So Here's a function to generate a UUIDv4: http://stackoverflow.com/a/2040279 It works great. I've used it in the past. You can optionally leave out the dashes if you want it to be a bit shorter, then it'll be 32 characters just like md5's output. Sorry for the long answer. Thoughts on UUIDv4? |
Preach on. Agreed with this being a perfect application of a UUIDv4 generated string. |
lol |
I posted my UUID class https://github.com/j20/php-uuid A token can be generated using UUID::v4(false); |
@andrew13, that would be nice :) |
@andrew13 Yeah. No problem. I'll get that reformatted for Packagist, probably tomorrow, and will drop a link here when it's done. |
Got it working. Thanks for the help via email Andrew. https://github.com/j20/php-uuid https://packagist.org/packages/j20/php-uuid |
@j20 Awesome, I'll get the updates posted shortly :) |
Otherwise the md5 string can be decrypted and the application string is reveled. Which is a security concern.