Repository navigation
Commit d65a08e
committed
fix(encryption): check the size of an AES-GCM wrapped key before unwrapping it
A128GCMKW, A192GCMKW and A256GCMKW hand the whole encrypted key to
openssl_decrypt(), which decrypts it before checking the authentication
tag, for every key of the key set. The size check added for the AES Key
Wrap algorithms skipped them, so a token with an encrypted key of any
size was rejected only after work and memory proportional to that size.
AES-GCM key wrapping returns as many bytes as it wraps, its tag being the
"tag" header parameter: JWEDecrypter now compares the size of the
encrypted key with the CEK size before calling these algorithms. The
tokens it rejects are the ones it already rejected, either because the
tag did not match or because the unwrapped key had the wrong size: only
the failure passed to the callable of decrypt() and chained by the
loaders changes.
Reported by inanna-malick, as a follow-up of ANT-2026-GFP863VS.1 parent 011e764 commit d65a08e
2 files changed
Lines changed: 18 additions & 9 deletions
File tree
- src/Library/Encryption
- tests/Component/Encryption
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
324 | | - | |
325 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
326 | 328 | | |
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | 333 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
336 | 342 | | |
337 | 343 | | |
338 | | - | |
| 344 | + | |
339 | 345 | | |
340 | 346 | | |
341 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
169 | 172 | | |
170 | 173 | | |
171 | 174 | | |
| |||
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
248 | | - | |
249 | | - | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
| |||
0 commit comments