#414 - Switch from md5 to SHA-512 hashing

Identifier #414
Issue type Feature request or suggestion
Title Switch from md5 to SHA-512 hashing
Status Completed
Tags

Risk: Database change (custom)

Handling member Chris Graham
Addon core_cns
Description Update Composr password storage. Currently if someone gets the hash+salt via some other security hole (either on server, or from getting cookie hashes), they can use a server farm (e.g. Amazon instances, or some government farm) to generate rainbow tables for the salt used, and eventually get a password back. It's expensive, but within the means of larger organisations. This is made possible because techniques have been found to make md5 collisions easier than originally thought, but also because rainbow tables have become easier to produce due to increased computer power.

The solution is to move to using the PHP 'crypt' function instead of the 'md5' function, which is stronger, and harder to compute rainbow tables for due to it's execution time.

Using crypt allows complexity to be ramped up via configuration adjustments, by storing crypt-style salts that encode hash options in them; crypt allows configurable algorithmic [computational] complexity. We can therefore improve future password generation in Composr as hardware improves, without slowing down current hardware by being too strong off the bat. We should start with SHA-512 with some appropriate 'rounds' number; SHA-512 which is well supported in more modern versions of PHP.

The following files would need to use a new password API, for checking/generating password hashes:
- cns_members_action2.php
- cns_members_action.php
- lostpassword.php
- ejabberd_auth.php
- cns.php
- passwd.php
- password_rules.php
The API would use the same flexible password mechanisms Composr currently uses, but with support for the new 'crypt' method.

'crypt' is supported in PHP5.3+, effectively. So we would need to raise our minimum requirements. Older versions of PHP have the function, but rely on operating system availability which is no good for site portability because existing hashes could stop working if a new server does not support what an old server did.

(NB: A lot of systems moved to sha1 years ago instead of md5, but this is as bad as md5, and not available in our current system requirements -- so we're fortunate to have skipped a pointless change cycle and now be targeting the next generation mechanism in PHP)

(NB: It is important to point out that md5 is not inherently insecure per-se, it is only insecure if you find a way to grab a user's hash, which should not be possible anyway, and then you need to spend serious resources reversing the hash to a password)

---

As well as using this system for member passwords, we should do it for the site master password also.
Steps to reproduce

Funded? No
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Rating

Unrated