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

Timing attacks possible with example auth #91

Open
Nekyt opened this issue Aug 1, 2024 · 0 comments
Open

Timing attacks possible with example auth #91

Nekyt opened this issue Aug 1, 2024 · 0 comments

Comments

@Nekyt
Copy link

Nekyt commented Aug 1, 2024

Passwords must be compared using special functions, see example in nodejs link at the end.
A simple == might lead to timing attacks.
Therefore I think the examples should say that it is shown "as is" to illustrate a topic but shouldn't be used in production.
In this example https://scalatra.org/guides/3.0/http/authentication.html the password is compared with == instead of a special function
Extract from guide:
protected def validate(userName: String, password: String): Option[User] = {
if(userName == "scalatra" && password == "scalatra") Some(User("scalatra"))
else None
See
https://en.wikipedia.org/wiki/Timing_attack
https://nodejs.org/api/crypto.html#cryptotimingsafeequala-b
https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/security/MessageDigest.html#isEqual(byte%5B%5D,byte%5B%5D)

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

1 participant