Commit bbc8aab
committed
bug #62487 [Security] Fix
This PR was merged into the 7.3 branch.
Discussion
----------
[Security] Fix `UserBadge` validation bypass via identifier normalizer
| 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:
```php
// 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.
Commits
-------
e4a759d [Security] Fix UserBadge validation bypass via identifier normalizerUserBadge validation bypass via identifier normalizer (yoeunes)File tree
2 files changed
+38
-7
lines changed- src/Symfony/Component/Security/Http
- Authenticator/Passport/Badge
- Tests/Authenticator/Passport/Badge
2 files changed
+38
-7
lines changedLines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 59 | | |
66 | 60 | | |
67 | 61 | | |
| |||
74 | 68 | | |
75 | 69 | | |
76 | 70 | | |
| 71 | + | |
| 72 | + | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
| |||
132 | 128 | | |
133 | 129 | | |
134 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
72 | 95 | | |
0 commit comments