Skip to content

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

Merged
taylorotwell merged 8 commits into
laravel:8.xfrom
JensJI:feature/user-enumaration-vulnerability
Sep 21, 2022
Merged

[8.x] Patch for timeless timing attack vulnerability in user login#44069
taylorotwell merged 8 commits into
laravel:8.xfrom
JensJI:feature/user-enumaration-vulnerability

Conversation

@JensJI

@JensJI JensJI commented Sep 9, 2022

Copy link
Copy Markdown
Contributor

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.
Comment thread tests/Support/SupportHelpersTest.php
@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
Comment thread src/Illuminate/Auth/SessionGuard.php Outdated
Comment thread src/Illuminate/Auth/SessionGuard.php Outdated
Comment thread src/Illuminate/Auth/SessionGuard.php
Comment thread src/Illuminate/Auth/SessionGuard.php Outdated
Comment thread src/Illuminate/Auth/AuthManager.php Outdated
@taylorotwell
taylorotwell merged commit 3145c60 into laravel:8.x Sep 21, 2022
@driesvints

Copy link
Copy Markdown
Member

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

@lazerg

lazerg commented Sep 28, 2022

Copy link
Copy Markdown
Contributor

Thank you for the PR.

@mxp100

mxp100 commented Sep 28, 2022

Copy link
Copy Markdown

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

@pratikkuikel

Copy link
Copy Markdown

This PR is gold 🏅

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.