Passwords: check in constant time
The default password comparison logic does not use constant time validation. Switching to constant time offers a meager improvement by removing a timing oracle. A prepatory step in moving to Argon2id password storage, since we'll need this change anyway after for validating existing passwords. Co-authored-by: Graham Christensen <graham@grahamc.com>
This commit is contained in:
committed by
Graham Christensen
parent
d4d8f1ba1b
commit
29620df85e
29
t/Schema/Users.t
Normal file
29
t/Schema/Users.t
Normal file
@ -0,0 +1,29 @@
|
||||
use strict;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init();
|
||||
|
||||
require Hydra::Schema;
|
||||
require Hydra::Model::DB;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
my $db = Hydra::Model::DB->new;
|
||||
hydra_setup($db);
|
||||
|
||||
# Catalyst's default password checking is not constant time. To improve
|
||||
# the security of the system, we replaced the check password routine.
|
||||
# Verify comparing correct and incorrect passwords work.
|
||||
|
||||
# Starting the user with a sha1 password
|
||||
my $user = $db->resultset('Users')->create({
|
||||
"username" => "alice",
|
||||
"emailaddress" => 'alice@nixos.org',
|
||||
"password" => "8843d7f92416211de9ebb963ff4ce28125932878" # SHA1 of "foobar"
|
||||
});
|
||||
isnt($user, undef, "My user was created.");
|
||||
|
||||
ok(!$user->check_password("barbaz"), "Checking the password, barbaz, is not right");
|
||||
ok($user->check_password("foobar"), "Checking the password, foobar, is right");
|
||||
|
||||
done_testing;
|
Reference in New Issue
Block a user