I'm using Python's crypt package to persist encrypted passwords in a MySQL databse for a Django website. I'm not sure if this is a bug, but here's the code I'm using:
To encrypt/persist the password:
user.password = crypt(request.POST['password'], netid)
user.save()
To check for a correct password on login:
if crypt(password, email) == user.password:
# Grant acccess to the user's profile, etc.
The problem is the following. If I encrypt a password with variable netid = test@example.com
and request.POST['password'] = 'ABC123abc'
, it works fine. However, when I try to login, if I use the password 'ABC123abc[trailing_chars]'
, where the trailing_chars can be any valid string, I am still able to log in. Why is this? It poses to be a large security hole as is.