Commit 98b011d
fix(auth): pad to fixed length in safeCompare instead of self-compare
The previous safeCompare did a no-op timingSafeEqual(ab, ab) on length
mismatch which doesn't actually equalize cost (same memory, trivially
equal). Replace with the standard fixed-length padding pattern: copy
both inputs into 256-byte zero-padded buffers, timingSafeEqual on those,
and AND with a real length check. Inputs longer than 256 bytes are
rejected outright (well beyond any reasonable password).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3af53a5 commit 98b011d
1 file changed
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
297 | | - | |
298 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
299 | 302 | | |
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
308 | 313 | | |
309 | 314 | | |
310 | 315 | | |
| |||
0 commit comments