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

Compare user and pass hashes simultaneously to avoid leaking if the username is valid #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nvx
Copy link

@nvx nvx commented Sep 28, 2021

Currently the user and pass hashes are compared separately, if the username matches but not the password the middleware will return slightly faster than if both the username and password are wrong.

This change concatenates the user and pass hashes together and compares them in one call to subtle.ConstantTimeCompare removing any timing leaks.

I also added a go.mod file.

username is correct but not the password via a timing side channel.
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.

None yet

1 participant