Repository navigation
fix(sms): reject excess concurrent webhook reads - #136504
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 3:42 PM ET / 19:42 UTC. ClawSweeper reviewWhat this changesThis PR caps concurrent SMS webhook body reads before signature verification and returns a closed HTTP 429 when the route is full. Merge readiness✅ Ready for maintainer review Keep this valid, maintainer-labeled SMS reliability fix open. Current main still permits unbounded pre-auth body reads; the current head addresses both prior findings with the shared limiter and closed rejection lifecycle, with no blocking defect found. Priority: P2 Review scores
Verification
How this fits togetherThe SMS plugin registers an HTTP webhook route that reads and verifies Twilio forms before placing accepted messages into durable ingress. The change protects the route’s pre-authentication body-read stage without changing later delivery or inbound dispatch quotas. flowchart LR
A[SMS webhook callback] --> B[SMS account route]
B --> C[Pre-auth concurrency gate]
C -->|admitted| D[Read and verify form]
C -->|full| E[Closed 429 response]
D -->|valid| F[Durable SMS ingress]
D -->|invalid| G[Rejected callback]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +19, Tests +303. Total +322 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the account-route-local limiter and shared closed-rejection path, with the new socket-level regression protecting overflow, cleanup, and subsequent signed admission. Do we have a high-confidence way to reproduce the issue? Yes: current main reads every POST body before any concurrency admission, and the added real HTTP/TCP boundary scenario supplies a high-confidence reproduction shape without this read-only review executing it. Is this the best way to solve the issue? Yes: the route reuses the public per-key limiter while directly using the shared closed-rejection lifecycle; the generic pipeline helper would send a bare response on limiter overflow and would not preserve this transport invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7b0fc05505aa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
b429410 to
52bfb7f
Compare
Addressed both findings in
|
* fix(nextcloud-talk): reject excess concurrent webhook reads Acquire a listener-owned in-flight limiter slot before the unauthenticated webhook body read, reject overflow with a close-aware HTTP 429, and release the slot after signature verification but before authenticated dispatch. Incomplete requests previously pinned a pre-auth reader for the full timeout without consuming the authentication-failure budget, letting any reachable client hold unbounded numbers of sockets and readers to degrade webhook availability. This follows the owner-level pattern merged for SMS (#136504) and Feishu (#137230). * fix(nextcloud-talk): preserve queued acknowledgements under pipelined overflow Serialize webhook admission per connection through the shared HTTP request lifecycle (runHttpConnectionRequest, re-exported on the plugin SDK guards subpath) so a pipelined request's overflow rejection only starts after every earlier response on the connection finished. Covers the reviewed sequence with real TCP: a saturated keep-alive connection with admission pending past the one-second close timer must still deliver the earlier signed 200 before the close-aware 429. * docs(nextcloud-talk): document overload admission and SDK connection ordering Record the 64-slot admission bound, its close-aware 429 overflow behavior, ordered keep-alive acknowledgements, and the unverified sender-redelivery risk in the channel guide. Document runHttpConnectionRequest's response-completion and closure semantics for plugin-owned webhook listeners on the SDK infrastructure page. * docs(nextcloud-talk): correct overload mitigation guidance The 64-read admission budget is hard-coded and not configurable, so raising reverse-proxy connection limits cannot relieve saturation and can feed more requests into the rejection path. Advise reducing or buffering upstream concurrency instead, and state plainly that the budget is fixed.
…#146356) * fix(nextcloud-talk): reject excess concurrent webhook reads Acquire a listener-owned in-flight limiter slot before the unauthenticated webhook body read, reject overflow with a close-aware HTTP 429, and release the slot after signature verification but before authenticated dispatch. Incomplete requests previously pinned a pre-auth reader for the full timeout without consuming the authentication-failure budget, letting any reachable client hold unbounded numbers of sockets and readers to degrade webhook availability. This follows the owner-level pattern merged for SMS (openclaw#136504) and Feishu (openclaw#137230). * fix(nextcloud-talk): preserve queued acknowledgements under pipelined overflow Serialize webhook admission per connection through the shared HTTP request lifecycle (runHttpConnectionRequest, re-exported on the plugin SDK guards subpath) so a pipelined request's overflow rejection only starts after every earlier response on the connection finished. Covers the reviewed sequence with real TCP: a saturated keep-alive connection with admission pending past the one-second close timer must still deliver the earlier signed 200 before the close-aware 429. * docs(nextcloud-talk): document overload admission and SDK connection ordering Record the 64-slot admission bound, its close-aware 429 overflow behavior, ordered keep-alive acknowledgements, and the unverified sender-redelivery risk in the channel guide. Document runHttpConnectionRequest's response-completion and closure semantics for plugin-owned webhook listeners on the SDK infrastructure page. * docs(nextcloud-talk): correct overload mitigation guidance The 64-read admission budget is hard-coded and not configurable, so raising reverse-proxy connection limits cannot relieve saturation and can feed more requests into the rejection path. Advise reducing or buffering upstream concurrency instead, and state plainly that the budget is fixed.
What Problem This Solves
Incomplete SMS webhook uploads could remain in pre-authentication body parsing without a route-level concurrency bound. Enough simultaneous incomplete uploads could occupy SMS webhook handling capacity, while a bare overflow response could leave the unread connection open.
Why This Change Was Made
The SMS account route now uses the public
createWebhookInFlightLimiterwith one account-route key and a 64-request limit. Admission occurs before the Twilio form body is read, and the slot is released in afinallyafter signature verification. Existing post-authentication sender, aggregate, delivery, and invalid-request accounting remains separate.Overflow is rejected through
sendHttpRequestRejection, preserving the shared HTTP rejection lifecycle: the response is HTTP 429 withConnection: close, the socket is half-closed after the response is written, and subsequent unread input remains bounded.The rebase also preserves the newer shared rejection handling for oversized and timed-out SMS webhook bodies.
User Impact
SMS webhook handling remains available when many clients hold form uploads incomplete. Up to 64 pre-authentication reads may proceed for an account route; excess requests receive a closed HTTP 429 response. Capacity returns as soon as admitted requests finish parsing and verification, and valid signed Twilio callbacks continue into the existing durable inbound path.
Evidence
Added a real-boundary test that starts the SMS account through
startSmsGatewayAccount, obtains the production-created route from the plugin HTTP registry, and hosts that real route handler on a Node HTTP server. It uses real HTTP and TCP clients to exercise overflow, connection closure, capacity recovery, signature verification, and durable ingress admission.Redacted executed trace:
This proves the production-owned SMS account route bounds incomplete pre-authentication uploads, closes overflow connections, recovers capacity, and admits a validly signed form into durable ingress. This evidence does not include a live Twilio callback.
Validation:
pnpm test extensions/sms/src/webhook.boundary.test.ts— 1 test passed.pnpm test extensions/sms— 18 files and 359 tests passed.git diff --checkpassed.pnpm buildpassed.Final commit:
52bfb7faaafadb805d5f8f4e426cab3f6aed5803