Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #18182 -- Raw password echoed on authentication if no hashing used #34

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions django/contrib/auth/hashers.py
Expand Up @@ -16,7 +16,7 @@


def is_password_usable(encoded):
return (encoded is not None and encoded != UNUSABLE_PASSWORD)
return (encoded is not None and encoded != UNUSABLE_PASSWORD and ('$' in encoded or len(encoded) == 32))


def check_password(password, encoded, setter=None, preferred='default'):
Expand All @@ -35,7 +35,7 @@ def check_password(password, encoded, setter=None, preferred='default'):
password = smart_str(password)
encoded = smart_str(encoded)

if len(encoded) == 32 and '$' not in encoded:
if '$' not in encoded:
hasher = get_hasher('unsalted_md5')
else:
algorithm = encoded.split('$', 1)[0]
Expand Down
5 changes: 5 additions & 0 deletions django/contrib/auth/tests/hashers.py
Expand Up @@ -90,6 +90,11 @@ def doit():
make_password('letmein', hasher='lolcat')
self.assertRaises(ValueError, doit)

def test_bad_encoded_pasword(self):
encoded = 'letmeinbadencoded'
self.assertFalse(is_password_usable(encoded))


def test_low_level_pkbdf2(self):
hasher = PBKDF2PasswordHasher()
encoded = hasher.encode('letmein', 'seasalt')
Expand Down