Skip to content

Conversation

@yoeunes
Copy link
Contributor

@yoeunes yoeunes commented Nov 23, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

The UserBadge constructor validates that the identifier is not empty and does not exceed MAX_USERNAME_LENGTH.

However, when using $identifierNormalizer, the normalized identifier is computed lazily in getUserIdentifier() without validation. This allows normalizers to return invalid values:

// This correctly triggers a deprecation in the constructor
new UserBadge(''); 

// This currently bypasses validation and returns an empty string
$badge = new UserBadge('valid_input', null, null, fn() => ''); 
$badge->getUserIdentifier(); 

Related to #51744 and #61183

I targeted 7.3 as it introduced identifierNormalizer, please let me know if I should target 8.0 or 8.1 instead.

@yoeunes yoeunes force-pushed the security-user-badge-normalization branch from de51e46 to e4a759d Compare November 23, 2025 02:26
@OskarStark OskarStark changed the title [Security] Fix UserBadge validation bypass via identifier normalizer [Security] Fix UserBadge validation bypass via identifier normalizer Nov 23, 2025
@nicolas-grekas
Copy link
Member

Thank you @yoeunes.

@nicolas-grekas nicolas-grekas merged commit bbc8aab into symfony:7.3 Nov 24, 2025
11 checks passed
@fabpot fabpot mentioned this pull request Nov 27, 2025
This was referenced Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants