Commit 81556be
committed
fix(kilo-chat): cap request body sizes on inbound webhook and controller proxy
Both the plugin's inbound webhook (readBody) and the controller's
kilo-chat proxy routes previously buffered the full request body into
memory with no size cap. A malformed or adversarial caller could send
a multi-MB body and exhaust the Fly machine's memory budget, taking
down other tenants sharing the instance.
- Plugin webhook readBody: track cumulative bytes and throw
WebhookBodyTooLargeError once the 1 MB cap is exceeded; handler
maps this to HTTP 413.
- Controller proxy routes: check Content-Length before c.req.text()
and reject with 413 if over the cap. 1 MB for send/edit (message
content can legitimately be large); 8 KB for typing / reactions /
delete where payloads are tiny.
Caller is already authenticated (OPENCLAW_GATEWAY_TOKEN), but this
is defense-in-depth: a buggy or compromised plugin is the realistic
threat, and the fix is cheap.1 parent 7655e92 commit 81556be
4 files changed
Lines changed: 148 additions & 3 deletions
File tree
- services/kiloclaw
- controller/src/routes
- plugins/kilo-chat/src
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
13 | 38 | | |
14 | 39 | | |
15 | 40 | | |
| |||
21 | 46 | | |
22 | 47 | | |
23 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
24 | 52 | | |
25 | 53 | | |
26 | 54 | | |
| |||
52 | 80 | | |
53 | 81 | | |
54 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
55 | 87 | | |
56 | 88 | | |
57 | 89 | | |
| |||
88 | 120 | | |
89 | 121 | | |
90 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
91 | 126 | | |
92 | 127 | | |
93 | 128 | | |
| |||
130 | 165 | | |
131 | 166 | | |
132 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
133 | 172 | | |
134 | 173 | | |
135 | 174 | | |
| |||
166 | 205 | | |
167 | 206 | | |
168 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
169 | 212 | | |
170 | 213 | | |
171 | 214 | | |
| |||
199 | 242 | | |
200 | 243 | | |
201 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
202 | 249 | | |
203 | 250 | | |
204 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
| 263 | + | |
254 | 264 | | |
255 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
256 | 271 | | |
257 | 272 | | |
258 | 273 | | |
| |||
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
266 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
267 | 293 | | |
268 | 294 | | |
269 | 295 | | |
| |||
0 commit comments