fix(webhook): cap chunked request bodies - #13336
Conversation
|
Related to PR #3955 — same webhook chunked body limit fix. Maintainers should pick one. |
|
Thanks for pointing to #3955. I compared the two patches: #3955 relies on aiohttp client_max_size plus a post-read length check, while this PR enforces max_body_bytes while streaming chunked/no-length bodies and includes a regression that verifies the fallback request.read() path is not used after overflow. If maintainers prefer the older PR I’m fine deferring, but this one is rebased and targets the chunked-body bypass directly. |
|
stale base This PR has not incorporated the base branch in 60 days. Please rebase or merge if it's still relevant. Signed: GPT-5.5-low in Codex |
Competing with the earlier open #3955 for the same #12543 chunked-body bypass — #3955 uses aiohttp |
|
Thanks for the focused chunked-body protection work. This is already implemented on current
Closing as implemented on main. |
Fixes #12543.
Root cause:
The webhook adapter only enforced
max_body_bytesfromrequest.content_length. Chunked requests withoutContent-Lengthwere treated as length zero, thenrequest.read()pulled the full body into memory before validation.Fix summary:
Content-Lengthrejection for known oversized bodies.request.content.iter_chunked()and return 413 as soon as the accumulated body exceedsmax_body_bytes.request.read()or dispatching the webhook.Tests:
uv run --frozen --python 3.11 --extra dev pytest -o addopts= tests/gateway/test_webhook_adapter.py -q->37 passedgit diff --check -- gateway/platforms/webhook.py tests/gateway/test_webhook_adapter.py