You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When JsonLoginAuthenticator does its job, among other things, it checks that the username passed in the request is a string and that it is not longer than 4096 characters:
thrownewBadRequestHttpException(sprintf('The key "%s" must be a string.', $this->options['password_path']));
}
} catch (AccessException$e) {
thrownewBadRequestHttpException(sprintf('The key "%s" must be provided.', $this->options['password_path']), $e);
}
return$credentials;
I propose to additionally check that both username and password consist of at least one character each, so that attempts to login with an empty username or password are refused without making attempts to load the user.
and attempt to trigger a JSON login with blank username and password. You will see that no BadRequestHttpException will be caught here and that the logic will proceed creating a Passport object with two useless badges, one for blank username and another for blank password:
…d (bikalbasnet)
This PR was squashed before being merged into the 6.2 branch.
Discussion
----------
[Security] Don't allow empty username or empty password
| Q | A
| ------------- | ---
| Branch? | 6.2
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Tickets | #46100
| License | MIT
| Doc PR | -
<!--
Replace this notice by a short README for your feature/bugfix.
This will help reviewers and should be a good start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against the latest branch.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
- Never break backward compatibility (see https://symfony.com/bc).
-->
Reopened from #46109 into `6.1` branch as this is not a bug rather a security feature
Commits
-------
db5afbd [Security] Don't allow empty username or empty password
Symfony version(s) affected
All currently supported versions
Description
When JsonLoginAuthenticator does its job, among other things, it checks that the username passed in the request is a string and that it is not longer than 4096 characters:
symfony/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Lines 147 to 159 in f99f54a
Further down below it makes sure that the supplied password is also a string:
symfony/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Lines 161 to 171 in f99f54a
I propose to additionally check that both username and password consist of at least one character each, so that attempts to login with an empty username or password are refused without making attempts to load the user.
How to reproduce
Enable debugging, add a breakpoint in
symfony/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Line 82 in f99f54a
symfony/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Lines 79 to 98 in f99f54a
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: