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

[8.x] Patch for timeless timing attack vulnerability in user login #44069

Merged

Conversation

JensJI
Copy link
Contributor

@JensJI JensJI commented Sep 9, 2022

Timebox class

This new Timebox class makes a callable execute for at least the supplied amount of time.

This helps us guard against timing attacks at the application.

Timeless timing attacks

The authentication method is currently vulnerable to user enumeration via timeless timing attacks.
This is caused by the early return inside the hasValidCredentials method in the Illuminate\Auth\SessionGuard class.

If the user does not exist most of the code in that method will not be called and thus the execution time will be a tiny bit shorter.

With traditional timing attacks this would not be practical to utilize because of the large sample sizes needed, but timeless timing attacks which uses the HTTP/2 multiplexing protocol can with high accuracy measure timing differences between two calls to a remote server on 20 microseconds with a sample size of only 6 request pairs.

This means that most throttling/max attempts/DoS attack protection etc will not be triggered, and it is suddently very practical to harvest existing emails for a site (user enumeration).

User enumeration in itself is a security problem for some sites (where users dont want others to know they are using that site), but in general user enumeration can be used in tandem with other attacks (e.g. brute-forcing passwords or using previously leaked passwords).

The patch

That is why the new Timebox class is also implemented inside the hasValidCredentials method in this PR.

A demo script that can be used to exploit the user enumeration can be found here.

The changes in this PR add a minimum execution time for the hasValidCredentials method of 200 milliseconds.
But if the credentials are correct the timebox will be escaped and the user would not have to wait.

So this change only affects users typing the wrong credentials.

This pull request is opened with permission from Taylor via e-mail.

More in depth explanation of timeless timing attacks can be found here.

…sleep as part of the test. This is necessary because usleep on Windows is unreliable, and other tests that uses CPU (for instance by using usleep) that run simultaneously are then affecting the tests in SupportHelpersTests.php that asserts based on the used time.
@driesvints driesvints changed the title Patch for timeless timing attack vulnerability in user login [8.x] Patch for timeless timing attack vulnerability in user login Sep 13, 2022
@taylorotwell taylorotwell merged commit 3145c60 into laravel:8.x Sep 21, 2022
@driesvints
Copy link
Member

I merged this into 9.x as well so this will be included in the next release.

@lazerg
Copy link

lazerg commented Sep 28, 2022

Thank you for the PR.

@mxp100
Copy link

mxp100 commented Sep 28, 2022

May be correctly create this timeout in AuthManager and fix this attack for all drivers (not only Session) ?

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

10 participants