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

Add password strength option #31

Merged
merged 14 commits into from
Jan 23, 2019
Merged

Conversation

leportella
Copy link
Collaborator

Closes #22

Copy link
Contributor

@yuvipanda yuvipanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Password complexity requirements around mixing cases has generally proven to lead to less secure passwords and not more - the general suggestion today is to not do that. Instead, what we should do is to check password against a common list of passwords - such as https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/10-million-password-list-top-10000.txt - and disallow that.

See https://auth0.com/blog/dont-pass-on-the-new-nist-password-guidelines/ for more information, and a link to the NIST guidelines themselves.

@leportella
Copy link
Collaborator Author

Nice article @yuvipanda ! Thanks. I changed it check for size and that if it is too common

@leportella leportella force-pushed the add-password-strength-option branch from e3fb956 to 7dfbefb Compare January 16, 2019 10:31
@leportella leportella force-pushed the add-password-strength-option branch from 662b27a to 6e1027f Compare January 16, 2019 10:48
Copy link
Contributor

@yuvipanda yuvipanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

I left a few suggested changes. Can you also add docs or a script on where the list of common passwords comes from and how to update it?


result_message = 'Your information have been sent to the admin'
if not user:
result_message = """Something went wrong. Be sure your password
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This length should be configurable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


from .common_credentials import COMMON_CREDENTIALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a .txt file instead of a .py file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this but I would have to everytime open a file, create a list and then search in the list. I thought that if I already had a list, it would be more efficient. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can we read it once - on first use and cache it? As a static method maybe? This also means it isn't loaded into memory unless it is needed.

I try to avoid Python files where possible for pure data, since any mistakes there - especially in massive files - can execute arbitrary code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to do this using cache. Could you give me an example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! something like

common_passwords.py

COMMON_PASSWORDS = None

def is_password_common(password):
    global COMMON_PASSWORDS
    if COMMON_PASSWORDS == None:
        with open("path-to-file") as f:
            COMMON_PASSWORDS = f.readlines()
    return password in COMMON_PASSWORDS

How does that sound?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Ok! Great!

@leportella
Copy link
Collaborator Author

@yuvipanda I just added a new pull request for docs only

@leportella leportella force-pushed the add-password-strength-option branch from c9d64b7 to ea07fdf Compare January 17, 2019 18:45
Copy link
Contributor

@yuvipanda yuvipanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments but can be merged after this :)

if not self.COMMON_PASSWORDS:
with open(common_credentials_file) as f:
self.COMMON_PASSWORDS = f.read().splitlines()
return password.lower() in self.COMMON_PASSWORDS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does COMMON_PASSWORDS only contain lowercase characters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it doesn't. I removed this lower() method :)

return password.lower() in self.COMMON_PASSWORDS

def is_password_strong(self, password):
checks = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be two config options:

  1. disallow_common_passwords - Checks if password used is common. Default to True
  2. minimum_password_length - Only allow passwords longer than this. Can be set to 0 to disable length checking. Defaults to 8.

Also, when checking a constant number of variables like this, it's clearer to just use a boolean expression directly len(password) >= self.minimum_password_length and not self.is_common_password(password) than using all

result_message = 'Your information have been sent to the admin'
if not user:
result_message = """Something went wrong. Be sure your password
has at least 8 characters and is not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should refer to the actual configured length rather than be hardcoded to 8

@leportella leportella force-pushed the add-password-strength-option branch from 5a56f14 to c59ef08 Compare January 21, 2019 10:09
Copy link
Contributor

@yuvipanda yuvipanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3 LGTM!

@yuvipanda yuvipanda merged commit 449e08d into master Jan 23, 2019
@lambdaTotoro lambdaTotoro deleted the add-password-strength-option branch September 29, 2021 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants