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

Readme is unclear regarding timing attacks #956

Open
Fuzzypeg opened this issue Sep 29, 2022 · 3 comments
Open

Readme is unclear regarding timing attacks #956

Fuzzypeg opened this issue Sep 29, 2022 · 3 comments

Comments

@Fuzzypeg
Copy link

Fuzzypeg commented Sep 29, 2022

the README.md makes apparently contradictory statements regarding timing attacks:

The bcrypt comparison function is not susceptible to timing attacks.

And, the comparison function is not time safe. What that means is that it may exit the function early in the comparison process.

Which is it? Is it susceptible to timing attacks or not? I suspect the first of these statements is supposed to read "The bcrypt comparison function is susceptible to timing attacks"?

@recrsn
Copy link
Collaborator

recrsn commented Oct 2, 2022

Bcrypt is a first pre-image resistant hash algorithm which makes timing attacks improbable unless there is a severe flaw in bcrypt algorithm itself.

To create a timing attack for a hash comparison where you try to guess the plain text, the hash algorithm has to behave predictably for incremental variations of input. Algorithms which are first preimage resistant do not belong to this category.

Timing attacks are more relevant in context of signatures (such as JWT) where the server calculates a hash and compares it against an user supplied value. A non-constant time operation can leak the correct hash and you can perform a known plain-text attack to recover the private key.

@Fuzzypeg
Copy link
Author

Fuzzypeg commented Oct 3, 2022

@recrsn I understand what a timing attack is. What I don't understand is whether bcrypt's comparison function is susceptible. Because the README says that it is, and it also says that it isn't. Read what I quoted (above). Both statements can't be correct.

@recrsn
Copy link
Collaborator

recrsn commented Oct 6, 2022

Thanks for the clarification.

It should have been something similar to The bcrypt algorithm when used for its intended purpose, is not susceptible to timing attacks. Would you like to make a PR with the changes?

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

No branches or pull requests

2 participants