Skip to content

Commit

Permalink
Replace PBKDF2 with SHA-256 (fix #336)
Browse files Browse the repository at this point in the history
Ubuntu 14.04 doesn't have Python 2.7.8 (where pbkdf2 got added) :(
  • Loading branch information
fmarier committed May 3, 2015
1 parent bec55ff commit c13e3f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion plugins/php-auth/auth.php
Expand Up @@ -31,7 +31,10 @@ function check_password($email, $password) {
pg_close($dbconn);
print "\t ZK:\t" . $expectedhash . "\n";

$computedhash = hash_pbkdf2('sha256', $password, $ZKSALT . $usersalt, $ZKITERATIONS);
$salt = $ZKSALT . $usersalt;
// FIXME: switch back to PBKDF2 once Python 2.7.8 is in Ubuntu LTS (16.04)
//$computedhash = hash_pbkdf2('sha256', $password, $salt, $ZKITERATIONS);
$computedhash = hash('sha256', $password . $salt);
print "\t PHP:\t" . $computedhash . "\n";

return $expectedhash === $computedhash;
Expand Down
8 changes: 6 additions & 2 deletions zk/model/person.py
Expand Up @@ -119,8 +119,12 @@ def gen_password(self, value):
self.password_salt = salt.hexdigest()

salt = lca_info['password_salt'] + self.password_salt
dk = hashlib.pbkdf2_hmac('sha256', value, salt, lca_info['password_iterations'])
return binascii.hexlify(dk)
# FIXME: switch back to PBKDF2 once Python 2.7.8 is in Ubuntu LTS (16.04)
#dk = hashlib.pbkdf2_hmac('sha256', value, salt, lca_info['password_iterations'])
#return binascii.hexlify(dk)
h = hashlib.new('sha256')
h.update(value + salt)
return h.hexdigest()

def _set_password(self, value):
if value is not None:
Expand Down

1 comment on commit c13e3f2

@chort
Copy link

@chort chort commented on c13e3f2 Oct 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least you should use $ZKITERATIONS rounds of sha256 as some minimal protection against brute-forcing (which still wouldn't provide the memory hardness of PBKDF2, Bcrypt, or Scrypt). This change eviscerates brute-force protection in the stored password hashes. A malicious attacker with access to the hashes can trivially find collisions (i.e. "crack the passwords").

Please sign in to comment.