Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add pepper to password hashing #907

Merged
merged 5 commits into from
Jul 5, 2016
Merged

Conversation

KentShikama
Copy link
Contributor

Random pepper generated by

dd if=/dev/urandom bs=1k count=1 2>/dev/null | base64
HR32t0xZcQnzn3O0ZkEVuetdFvH1W6TeEPw6JjH0Cl+qflVOseGyFJlJR7ACLnywjN997kuy9kbN
bBCUiAWT/630Dd8qsBHu6+nZGnsQ4FH0Eo5Psh+NFoDUSIwYQRUWW+3jSSZMPYb7qvBl+ww3j9f+
5l+BlhhiV7QOUTJwCWTvp0G+Rb2C0SVATswaxNnf79bC9Dme8/CKhlfx0KVuYnEOhkOEEMn99xy3
/DxE3O6njWH1HkiE20iLUERPhtnBeQXm10ZzWenIUC4mEXXBXAffRgRgqiSm3e6sv4ngPBdrAekt

I took the first x characters so the line length was 89 to fit within the < 90 char limit.

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

4 similar comments
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

"""
# Uncomment for extra security for your passwords.
# DO NOT CHANGE THIS AFTER INITIAL SETUP!
#pepper: "HR32t0xZcQnzn3O0ZkEVuetdFvH1W6TeEPw6JjH0Cl+qflVOseGyFJlJR7ACLnywjN9"
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this need to be a secret to each instance? I'd prefer if we instead had it like:

# Uncomment for extra security for your passwords.
# Change to a secret random string.
# DO NOT CHANGE THIS AFTER INITIAL SETUP!
#pepper: "<SOME_SECRET_RANDOM_STRING>"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it does indeed

@erikjohnston erikjohnston self-assigned this Jul 5, 2016
@erikjohnston
Copy link
Member

@matrixbot ok to test

@@ -763,6 +764,7 @@ def validate_hash(self, password, stored_hash):
Whether self.hash(password) == stored_hash (bool).
"""
if stored_hash:
return bcrypt.hashpw(password, stored_hash.encode('utf-8')) == stored_hash
return bcrypt.hashpw(password + self.hs.config.password_config.pepper,
Copy link
Member

Choose a reason for hiding this comment

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

self.hs.config.password_config.pepper should be self.hs.config.pepper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops…I wonder how this passed on my local machine. Perhaps I forgot to restart the server once I removed the hardcoded pepper I was testing with.

@erikjohnston
Copy link
Member

(I think the dendron test failure is nothing to do with this PR)

@erikjohnston
Copy link
Member

Thanks for this! :)

@erikjohnston erikjohnston merged commit e34cb5e into matrix-org:develop Jul 5, 2016
@KentShikama KentShikama deleted the pepper branch July 5, 2016 10:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants