Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Enforce maximum username length in UserBadge#46584

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.2fromwouterj:security-usernamelengthcheck
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletionsUPGRADE-6.2.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
UPGRADE FROM 6.1 to 6.2
=======================

Security
--------

* Add maximum username length enforcement of 4096 characters in `UserBadge` to
prevent [session storage flooding](https://symfony.com/blog/cve-2016-4423-large-username-storage-in-session)

Validator
---------

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@

use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\EventListener\UserProviderListener;
Expand All@@ -27,6 +28,8 @@
*/
class UserBadge implements BadgeInterface
{
public const MAX_USERNAME_LENGTH = 4096;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps out of context but why reintroducing username here? Why not user identifier?

alessandro-podo reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need a more advanced BC layer for that. I'm going to work on getting rid of that "username" leftovers in a dedicated PR if we don't do it here (there's also Security::LAST_USERNAME)


private string $userIdentifier;
/** @var callable|null */
private $userLoader;
Expand All@@ -47,6 +50,10 @@ class UserBadge implements BadgeInterface
*/
public function __construct(string $userIdentifier, callable $userLoader = null)
{
if (\strlen($userIdentifier) > self::MAX_USERNAME_LENGTH) {
throw new BadCredentialsException('Username too long.');
}

$this->userIdentifier = $userIdentifier;
$this->userLoader = $userLoader;
}
Expand Down
5 changes: 5 additions & 0 deletionssrc/Symfony/Component/Security/Http/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.2
---

* Add maximum username length enforcement of 4096 characters in `UserBadge`

6.0
---

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp