Skip to content

fix(sms): reject excess concurrent webhook reads - #136504

Merged
drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-985
Sep 2, 2026
Merged

drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-985

Conversation

@drobison00

@drobison00 drobison00 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Devin Robison · GPT-5 Codex · via @drobison00

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 createWebhookInFlightLimiter with one account-route key and a 64-request limit. Admission occurs before the Twilio form body is read, and the slot is released in a finally after 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 with Connection: 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:

held incomplete POSTs: 64/64 body readers active
65th incomplete POST: HTTP/1.1 429 Too Many Requests
65th response header: Connection: close
65th client event: server end observed=true
65th request complete: false
durable ingress calls before release: 0
held requests completed: 64; expected invalid-signature responses: 64 x HTTP 403
next signed POST: HTTP 200
next signed POST header: x-openclaw-delivery-accepted=durable
durable ingress calls after recovery: 1

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.
  • Path-scoped changed-file checks passed, including format, production/test typechecks, lint, public SDK boundaries, dead-export scans, and import-cycle checks.
  • git diff --check passed.
  • pnpm build passed.

Final commit: 52bfb7faaafadb805d5f8f4e426cab3f6aed5803

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: sms Channel integration: sms size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 3:42 PM ET / 19:42 UTC.

ClawSweeper review

What this changes

This 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
Reviewed head: 52bfb7faaafadb805d5f8f4e426cab3f6aed5803

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with credible real transport proof and no supported blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.
Evidence reviewed 6 items Introduced pre-auth bound: The PR creates one limiter for the account route, acquires it before form reading, and releases it unconditionally after parsing and authentication exits.
Shared rejection lifecycle: Overflow uses the established rejection owner, which frames the response, sets Connection: close, half-closes only after writing, and waits for closure.
Route ownership and caller: The gateway constructs the SMS handler for the account route and invokes it after the tokenless media precheck, so its single stable account-route key is the correct limiter scope.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +19, Tests +303. Total +322 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 59 40 +19
Tests 1 303 0 +303
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 362 40 +322

Review metrics

Metric Value Why it matters
Production versus test LOC production +19 net; tests +303 The small production increase establishes a route-level resource boundary, while the added test exercises the real HTTP/TCP route boundary.

Technical review

Best 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.

Labels

Label changes:

  • add P2: This is a bounded fix for SMS webhook availability under incomplete concurrent uploads.
  • add proof: sufficient: Contributor real behavior proof is sufficient. At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.

Label justifications:

  • P2: This is a bounded fix for SMS webhook availability under incomplete concurrent uploads.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.
  • proof: sufficient: Contributor real behavior proof is sufficient. At the changed SMS route owner, the supplied after-fix Node HTTP/raw-TCP boundary trace and corresponding test exercise injected incomplete uploads through the production-created route, observe closed 429 overflow, then observe recovery and durable signed admission.

Evidence

What I checked:

  • Introduced pre-auth bound: The PR creates one limiter for the account route, acquires it before form reading, and releases it unconditionally after parsing and authentication exits. (extensions/sms/src/webhook.ts:114, 52bfb7faaafa)
  • Shared rejection lifecycle: Overflow uses the established rejection owner, which frames the response, sets Connection: close, half-closes only after writing, and waits for closure. (src/infra/http-request-lifecycle.ts:193, 7b0fc05505aa)
  • Route ownership and caller: The gateway constructs the SMS handler for the account route and invokes it after the tokenless media precheck, so its single stable account-route key is the correct limiter scope. (extensions/sms/src/gateway.ts:119, 52bfb7faaafa)
  • Boundary behavior proof: The added boundary test hosts the production-registered route on a real Node HTTP server, holds 64 partial uploads, observes raw-TCP 429 and connection closure for the next request, then verifies a signed callback reaches durable ingress after capacity returns. The PR body includes the matching redacted after-fix trace. (extensions/sms/src/webhook.boundary.test.ts:199, 52bfb7faaafa)
  • Current-main necessity: Current main still proceeds directly from request setup to readTwilioWebhookForm without an in-flight admission guard, so the requested behavior is not already implemented. (extensions/sms/src/webhook.ts:127, 7b0fc05505aa)
  • Relevant feature history: Recent history connects the SMS path to the shared rejected-connection lifecycle and to prior SMS delivery and quota work; local deep-history comparison was limited by unavailable promisor objects, so no introduction attribution is asserted. (extensions/sms/src/webhook.ts:136, 32b4abb3413c)

Likely related people:

  • Eden: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • clawSean: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-02T18:36:17.886Z sha b429410aa60b19eab036de23737d0997c356058b :: needs real behavior proof before merge. :: [P1] Close the unread overflow request through the shared lifecycle | [P1] Reuse the shared webhook in-flight limiter

@drobison00

Copy link
Copy Markdown
Contributor Author

Devin Robison · GPT-5 Codex · via @drobison00

Addressed both findings in 52bfb7faaafadb805d5f8f4e426cab3f6aed5803:

  • Pre-body 429 rejection transport: You were right—the bare overflow response could leave the unread request socket open. Overflow now awaits sendHttpRequestRejection, returns HTTP 429 with Connection: close, and closes the connection through the shared rejected-request lifecycle.
  • Duplicate admission counter: You were right—the local counter duplicated the SDK policy. It is replaced by one account-route createWebhookInFlightLimiter with limit 64, acquisition before form parsing, and finally release after signature verification. Existing post-authentication accounting is unchanged.
  • Real-boundary proof: A production-created SMS account route is hosted on a real Node HTTP server. The test holds 64 incomplete bodies, verifies the 65th receives a closed 429 without completing its body, releases the held requests, then verifies the next validly signed form reaches durable ingress. The SMS suite passes 359 tests, path-scoped checks pass, and the full build passes. This evidence does not include a live Twilio callback.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 2, 2026
@drobison00
drobison00 enabled auto-merge (squash) September 2, 2026 21:49
@drobison00
drobison00 merged commit 46db48b into openclaw:main Sep 2, 2026
113 of 114 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
eleqtrizit added a commit that referenced this pull request Sep 13, 2026
* 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: sms Channel integration: sms maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant