Skip to content

Commit

Permalink
Random timer to avoid timing oracles and simple bruteforce attacks
Browse files Browse the repository at this point in the history
Important note: this is a security fix.
  • Loading branch information
liZe committed Apr 19, 2017
1 parent aef652f commit 190b1dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions radicale/auth/htpasswd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
import base64
import hashlib
import os

import random
import time

from .. import config

Expand Down Expand Up @@ -161,7 +162,10 @@ def is_authenticated(user, password):
if strippedline:
login, hash_value = strippedline.split(":")
if login == user:
# Allow encryption method to be overridden at runtime.
return _verifuncs[ENCRYPTION](hash_value, password)
if _verifuncs[ENCRYPTION](hash_value, password):
# Allow encryption method to be overridden at runtime.
return True
# Random timer to avoid timing oracles and simple bruteforce attacks
time.sleep(1 + random.random())
return False

0 comments on commit 190b1dd

Please # to comment.