mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-13 10:30:16 +00:00
No need to have avoid timing side-channel attack in user_add. We're just going to tell you if the user already exists anyway.
This commit is contained in:
parent
96edae33ed
commit
2f7b56e6a9
@ -8,7 +8,7 @@ Here is an overview of how user passwords are currently being stored in Plinth.
|
|||||||
|
|
||||||
1. We check if the username or password is empty. If so, return an error message.
|
1. We check if the username or password is empty. If so, return an error message.
|
||||||
|
|
||||||
2. Use bcrypt (from passlib) to encrypt the password and generate a random salt. This step is performed regardless of whether the user already exists.
|
2. Use bcrypt (from passlib) to encrypt the password and generate a random salt.
|
||||||
|
|
||||||
3. If the password length is over 4096, bcrypt raises an exception. We catch this exception and return an error message.
|
3. If the password length is over 4096, bcrypt raises an exception. We catch this exception and return an error message.
|
||||||
|
|
||||||
|
|||||||
@ -24,17 +24,15 @@ def add_user(username, passphrase, name='', email='', expert=False):
|
|||||||
if not passphrase: error = "Must specify a passphrase!"
|
if not passphrase: error = "Must specify a passphrase!"
|
||||||
|
|
||||||
if error is None:
|
if error is None:
|
||||||
# hash the password whether the user exists, to foil timing
|
if username in map(lambda x: x[0], cfg.users.get_all()):
|
||||||
# side-channel attacks
|
error = "User already exists!"
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
pass_hash = bcrypt.encrypt(passphrase)
|
pass_hash = bcrypt.encrypt(passphrase)
|
||||||
except PasswordSizeError:
|
except PasswordSizeError:
|
||||||
error = "Password is too long."
|
error = "Password is too long."
|
||||||
|
|
||||||
if error is None:
|
if error is None:
|
||||||
if username in map(lambda x: x[0], cfg.users.get_all()):
|
|
||||||
error = "User already exists!"
|
|
||||||
else:
|
|
||||||
di = {
|
di = {
|
||||||
'username':username,
|
'username':username,
|
||||||
'name':name,
|
'name':name,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user