Commit 44c20c4
fix(transport): use atomic checkAndRecord to prevent TOCTOU race
Revert to using checkAndRecord() for message rate limiting instead of
separate check and record calls. The separated approach had a TOCTOU
race where concurrent sends could all pass the check before any recorded,
bypassing the rate limit.
Yes, failed sends now consume quota, but this is necessary for security -
recording after send would allow attackers to make unlimited concurrent
attempts that bypass the rate limit.
Co-Authored-By: Claude Opus 4.5 <[email protected]>1 parent 1391562 commit 44c20c4
1 file changed
+5
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
348 | 347 | | |
349 | 348 | | |
350 | 349 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
365 | 355 | | |
366 | 356 | | |
367 | 357 | | |
| |||
415 | 405 | | |
416 | 406 | | |
417 | 407 | | |
418 | | - | |
419 | | - | |
420 | 408 | | |
421 | 409 | | |
422 | 410 | | |
| |||
0 commit comments