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

[5.5] Prevent authentication if 'password' is the only field specified to the auth 'attempt' method #22167

Merged
merged 1 commit into from
Nov 22, 2017

Conversation

damiengrandi
Copy link
Contributor

I figured out that calling this :

auth()->attempt(['password' => 'mypassword'])

will result to true if the first row returned from the database is also the one using this password, without the need to specify an identifier (email for example).
This happens because the foreach loop inside the retrieveByCredentials function will never call $query->where($key, $value) and then will systematicaly call $query->first() without any SQL condition applied.

You can easily reproduct this by trying to authenticate the user represented by the first row of your users table without specifying his email or username.

I don't think this is an expected behaviour.
This issue exists for 5.5 and 5.4 (I did not check older versions but I guess it's also present).

@alepeino
Copy link
Contributor

Refer #21975

@taylorotwell taylorotwell merged commit 16b5c3a into laravel:5.5 Nov 22, 2017
@GrahamCampbell GrahamCampbell changed the title Prevent authentication if 'password' is the only field specified to the auth 'attempt' method [5.5] Prevent authentication if 'password' is the only field specified to the auth 'attempt' method Nov 26, 2017
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.

3 participants