Commit 929642b
fix: negative Content-Length no longer bypasses bodySizeLimit (#3153)
Number("-1") is -1: neither `> limit` nor falsy, so a negative declared
length satisfied neither guard and the body streamed into the decoder
uncapped (195x the configured limit in the report). Validate the string
form — only a plain digit string is a declaration worth trusting to the
HTTP server's framing — and route anything non-conforming through the
bounded buffer alongside undeclared bodies.
Unreachable on stock node:http (its parser refuses the header first);
hardening for hand-rolled adapters, laxer edge parsers, and rewriting
proxies. Reported by @frenzzy with the guard-by-guard analysis and fix.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 08b4d1c commit 929642b
3 files changed
Lines changed: 71 additions & 6 deletions
File tree
- .changeset
- packages/web
- server-functions/src
- test/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2382 | 2382 | | |
2383 | 2383 | | |
2384 | 2384 | | |
2385 | | - | |
2386 | | - | |
2387 | | - | |
2388 | | - | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
2389 | 2390 | | |
2390 | 2391 | | |
2391 | 2392 | | |
| |||
2397 | 2398 | | |
2398 | 2399 | | |
2399 | 2400 | | |
2400 | | - | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
2401 | 2411 | | |
2402 | 2412 | | |
2403 | 2413 | | |
2404 | 2414 | | |
2405 | 2415 | | |
2406 | 2416 | | |
2407 | 2417 | | |
2408 | | - | |
| 2418 | + | |
2409 | 2419 | | |
2410 | 2420 | | |
2411 | 2421 | | |
| |||
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
91 | 141 | | |
92 | 142 | | |
93 | 143 | | |
| |||
0 commit comments