-
Notifications
You must be signed in to change notification settings - Fork 175
Reject passwords that cannot be encrypted #939
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
Open
aaronmdjones
wants to merge
4
commits into
master
Choose a base branch
from
amdj/refuse-unencrypted-passwords
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following test was performed with PBKDF2v2 in SCRAM mode being the only loaded crypto provider:
|
The following test was performed with Argon2 being the only loaded crypto provider, configured with a memory cost of 29 (512 GiB of RAM) on a machine with only 128 GiB:
|
At the moment, if services fails to encrypt a password, it will fall back to storing it in plain text in the database. This is clearly undesirable. This can happen for a couple of reasons off of the top of my head: - No encryption-capable crypto providers are loaded. This is extremely negligent, but is still possible. Services complains loudly every time it attempts to encrypt a password in this configuration, but that will not stop some negligent sysadmins from ignoring these messages and continuing to run it in this configuration. - pbkdf2v2 is the only encryption-capable crypto provider loaded, it is configured in SCRAM mode with GNU libidn for SASLprep normalisation, and the user supplies a password containing invalid UTF-8 byte sequences or ASCII control characters. - Either argon2 or scrypt are the only encryption-capable crypto provider loaded, and they are configured to use far more memory than the system has available; high enough to cause libc to fall back to a direct mmap(2), and high enough for the kernel's overcommit logic to reject it as extreme, returning NULL. This is because set_password() has no way to indicate to its caller whether it was able to encrypt the password or not. This commit forces set_password() to encrypt the password or return failure to its caller. The callers now check whether it was successful and abort their operation if it was not. Also add a note to the SASL SCRAM documentation mentioning the prohibited password characters, and the same to the help files for commands that take passwords (but only if the SASL SCRAM module is loaded).
f1052f6
to
9c996b6
Compare
This is a worthwhile modification to the verification logic which should help ensure that plaintext passwords stay around in the database for as little amount of time as possible. It does have the slight disadvantage that this would then immediately call back into the crypto module it just used to encrypt it in order to verify it, which would have twice the computational overhead. However, this would be a one-time cost for a single login attempt; after that, it would be encrypted already, and then it's the same computational cost as any other login attempt. Reported-By: [email protected]
Posession of a valid SETPASS token is equivalent to having a means of authentication, and we already log other authentication failures. Make sure we log this one. Reported-By: [email protected]
a3a0b4a
to
f2d6719
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the moment, if services fails to encrypt a password, it will fall back to storing it in plain text in the database. This is clearly undesirable. This can happen for a couple of reasons off of the top of my head:
No encryption-capable crypto providers are loaded.
This is extremely negligent, but is still possible. Services complains loudly every time it attempts to encrypt a password in this configuration, but that will not stop some negligent sysadmins from ignoring these messages and continuing to run it in this configuration.
pbkdf2v2 is the only encryption-capable crypto provider loaded, it is configured in SCRAM mode with GNU libidn for SASLprep normalisation, and the user supplies a password containing invalid UTF-8 byte sequences or ASCII control characters.
Either argon2 or scrypt are the only encryption-capable crypto provider loaded, and they are configured to use far more memory than the system has available; high enough to cause libc to fall back to a direct mmap(2), and high enough for the kernel's overcommit logic to reject it as extreme, returning NULL.
This is because set_password() has no way to indicate to its caller whether it was able to encrypt the password or not.
This commit forces set_password() to encrypt the password or return failure to its caller. The callers now check whether it was successful and abort their operation if it was not.
Also add a note to the SASL SCRAM documentation mentioning the prohibited password characters, and the same to the help files for commands that take passwords (but only if the SASL SCRAM module is loaded).