Skip to content

fix(feishu): reject excess concurrent webhook reads - #137230

Merged
Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-feishu-preauth-inflight
Sep 11, 2026
Merged

Patrick-Erichsen merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-feishu-preauth-inflight

Conversation

@Alix-007

@Alix-007 Alix-007 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Feishu webhook operators could lose inbound availability when many clients held request bodies incomplete before signature validation. Every request could occupy a raw-body reader until timeout, with no route-level concurrency bound.

Why This Change Was Made

The Feishu webhook owner now admits at most 64 concurrent pre-authentication body reads per account route. It reuses OpenClaw's shared webhook in-flight limiter and closed HTTP rejection lifecycle, so overflow receives HTTP 429 with Connection: close; every admitted slot is released after raw-body handling and signature validation, before authenticated parsing and event dispatch.

This follows the accepted owner-level pattern from merged SMS PR #136504. It does not change Feishu's existing per-client request-rate limit or post-authentication dispatch behavior.

User Impact

Feishu webhook handling remains available when incomplete uploads consume the pre-authentication read stage. Up to 64 reads may proceed for one account route; excess requests are closed with 429, and capacity returns when admitted requests finish or disconnect.

Evidence

Exact-head proof receipt

  • Product head SHA: f00aebcbada845d45d60f52e954666c647bd1dd5
  • Base SHA: 6c446343df30e7e831281327ddf403ebc5a82691
  • Production entry: the real Node HTTP request listener created by monitorWebhook() in extensions/feishu/src/monitor.transport.ts.
  • Canonical owner exercised: Feishu's account-local webhook transport, before readWebhookBodyOrReject() and isFeishuWebhookSignatureValid().
  • Recorder/readback boundary: raw TCP status line and connection close, server-side durable invocation recorder, HTTP response headers, and the signed recovery response.

Acceptance red, same test and transport with only the production change removed:

held incomplete POSTs: 64
65th POST after body timeout: HTTP/1.1 408 Request Timeout
response header: Connection: close
expected: HTTP 429 before body timeout
focused test: FAIL at monitor.webhook-security.test.ts:461
test scenario duration: 5.413s

Acceptance green at the exact head:

held incomplete POSTs: 64; every held socket still open before overflow
65th POST: HTTP/1.1 429 Too Many Requests
response header: Connection: close
durable invocations before release: 0
held bodies completed unsigned: 64 x HTTP 401
next correctly signed POST: HTTP 200
x-openclaw-delivery-accepted: durable
durable invocations after recovery: 1
focused test: PASS (487ms test case)

The overflow assertion requires the 429 response in less than 400ms. Held requests use a 5-second body timeout only in this scenario, so a timeout cannot masquerade as successful overflow admission.

Release-scope acceptance red, using the same real HTTP listener and request sequence with the slot held through dispatch:

signed POST admitted; durable event dispatch intentionally stalled
later complete POST with an invalid signature: HTTP 429
expected: HTTP 401 after signature validation gets its own pre-auth slot
focused test: FAIL — expected 429 to be 401

Release-scope acceptance green at the exact head:

signed POST admitted; durable event dispatch intentionally stalled
later complete POST with an invalid signature: HTTP 401
durable invocation count while stalled: 1
original signed POST after releasing the dispatch gate: HTTP 200
focused test: PASS (48ms test case)

This control proves authenticated downstream latency cannot consume the bounded pre-authentication read capacity. Timeout, body rejection, guard-trip, invalid-signature, and signature-exception paths all release through the same owner-scoped finally.

Focused verification:

Node 24.19 focused Vitest
monitor.webhook-security.test.ts + monitor.webhook-activity.test.ts
2 files passed; 14 tests passed

oxfmt --check (2 changed files)
all matched files use the correct format

oxlint --tsconfig extensions/feishu/tsconfig.json (2 changed files)
0 warnings; 0 errors

autoreview, P0-P2
scoped-clean; no accepted/actionable findings; patch correct (0.92)

node scripts/check-changed.mjs --base upstream/main -- <two changed files> classified the intended extensions and extensionTests lanes, but this host's Corepack shim could not load its missing cached [email protected]. The equivalent focused test, direct formatter, direct linter, and git diff --check pass; exact-head GitHub CI remains the full-tree gate.

Scope and impact

  • Files: 2
  • Production LOC: +59/-27 (net +32)
  • Test LOC: +238/-1
  • Existing-solutions preflight: reuses createWebhookInFlightLimiter and sendHttpRequestRejection from the public plugin SDK; no dependency, custom queue, or alternate HTTP lifecycle was added.
  • Sibling coverage: compared with the merged SMS pre-authentication limiter and the existing Beam, Google Chat, LINE, and generic-webhook users of the shared limiter. Feishu needs this placement because its signature contract consumes the complete raw body.
  • Config/default impact: none. The 64-request safety bound is transport-owned and introduces no openclaw.json or environment setting.
  • Protocol/schema/upgrade impact: none.
  • Security impact: availability hardening at the unauthenticated request boundary; authenticated payload semantics are unchanged.
  • Not live-tested: a real Feishu tenant callback. The proof uses the production Node HTTP route with real TCP sockets, the production signature validator, and a correctly signed recovery payload; it does not send any real channel message.
  • Cleanup: all sockets and the isolated webhook server are closed by the test. No existing OpenClaw, Feishu account, model, token, channel, or user data was modified.

Maintainer integration verification (2026-09-10)

Integrated current main 48b319e240fa5e8024b88efabe9f1de492939238 with a signed merge at c98ed1040e28bf33c7a7efbe6533daaa2cf5083c, preserving contributor ancestry. Resolved the two adjacent constant/import conflicts while retaining both the pre-authentication concurrency bound and main’s signed-timestamp freshness validation and rejection tests. The resulting diff against that main remains limited to the two intended Feishu files.

Independent source verification and fresh autoreview found no actionable defects. The existing real-TCP RED/GREEN, capacity recovery and stalled-dispatch evidence above remains the behavior baseline. A fresh Blacksmith Testbox attempt stopped before allocation because the local CLI was unauthenticated; no new remote test execution is claimed. Exact integrated-head CI is running here and must pass before landing.

The transport-owned limit intentionally returns 429 to any excess request, including legitimate bursts, until capacity returns. It does not alter signature validation or authenticated dispatch semantics.

Fresh integrated-head CI passed: run 34545481411, including 2,053 tests in 102 Feishu files. The hosted logs confirm excess-read rejection/recovery, capacity release before signed dispatch, and both stale/future signed timestamp rejection all passed together.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 8:19 PM ET / September 11, 2026, 00:19 UTC (Revision 5).

ClawSweeper review

What this changes

The Feishu plugin limits concurrent unauthenticated webhook body reads to 64 per account route, closes excess requests with HTTP 429, and releases capacity before event dispatch.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded fix absent from current main and the latest release. The earlier slot-release finding is resolved, the recorded transport proof is sufficient, and the assigned reviewer explicitly accepted the overload tradeoff. No blocking correctness findings remain.

Priority: P2
Reviewed head: c98ed1040e28bf33c7a7efbe6533daaa2cf5083c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with strong production-boundary evidence, resolved prior feedback, and no remaining actionable defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded real-TCP RED/GREEN evidence exercises Feishu’s production HTTP listener, demonstrates prompt overflow closure and signed recovery, and proves stalled dispatch does not retain read capacity. The integrated source preserves that sequence; live Feishu delivery is outside this internal admission claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded real-TCP RED/GREEN evidence exercises Feishu’s production HTTP listener, demonstrates prompt overflow closure and signed recovery, and proves stalled dispatch does not retain read capacity. The integrated source preserves that sequence; live Feishu delivery is outside this internal admission claim.
Evidence reviewed 9 items Introduced admission and release boundary: The pinned introduced delta adds route-local admission before body reading and releases capacity in finally before payload parsing or awaited dispatch. Signature validation remains mandatory.
Current main still needs the fix: Current main retains per-client request-rate checks and bounded individual body reads but lacks the account-route concurrent-reader limit. Its transport difference matches the intended production patch; this comparison supplies behavioral context, not introduction ownership.
Latest release comparison: The transport at the supplied v2026.9.3 release commit likewise enters body reading without concurrent-reader admission. The release blob was inspected through GitHub REST after local blob retrieval failed.
Findings None None.
Security None None.

How this fits together

Feishu’s webhook transport receives HTTP callbacks, reads their bodies, and verifies signatures before forwarding events to the plugin’s inbound dispatcher. This change bounds the unauthenticated reading stage.

flowchart TD
  A[Feishu HTTP callback] --> B[Route and request checks]
  B --> C{Read capacity available?}
  C -->|No| D[HTTP 429 and connection close]
  C -->|Yes| E[Bounded body read and signature check]
  E --> F[Release read capacity]
  F --> G{Valid signed payload?}
  G -->|Yes| H[Event dispatch and response]
  G -->|No| D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +32, Tests +236. Total +268 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 59 27 +32
Tests 1 237 1 +236
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 296 28 +268

Review metrics

Metric Value Why it matters
Admission bound 64 concurrent pre-auth reads per account route Excess callbacks, including legitimate bursts, receive HTTP 429; the assigned reviewer explicitly accepted this operational tradeoff.

Technical review

Best possible solution:

Retain the existing shared limiter and rejection lifecycle at Feishu’s pre-authentication boundary, with the explicitly accepted overload behavior and unchanged authenticated dispatch.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: concurrent incomplete POST bodies enter independent readers without an account-route cap on current main. Recorded before/after TCP evidence supports the repair; this read-only review did not execute tests.

Is this the best way to solve the issue?

Yes. The patch uses existing SDK primitives at the transport owner and releases capacity before downstream work; the meaningful overload tradeoff now has explicit reviewer acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b8e2dbc7ca42.

Labels

Label changes:

  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is focused availability hardening for Feishu’s optional webhook transport, with no demonstrated widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Recorded real-TCP RED/GREEN evidence exercises Feishu’s production HTTP listener, demonstrates prompt overflow closure and signed recovery, and proves stalled dispatch does not retain read capacity. The integrated source preserves that sequence; live Feishu delivery is outside this internal admission claim.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded real-TCP RED/GREEN evidence exercises Feishu’s production HTTP listener, demonstrates prompt overflow closure and signed recovery, and proves stalled dispatch does not retain read capacity. The integrated source preserves that sequence; live Feishu delivery is outside this internal admission claim.

Evidence

What I checked:

  • Introduced admission and release boundary: The pinned introduced delta adds route-local admission before body reading and releases capacity in finally before payload parsing or awaited dispatch. Signature validation remains mandatory. (extensions/feishu/src/monitor.transport.ts:469, c98ed1040e28)
  • Current main still needs the fix: Current main retains per-client request-rate checks and bounded individual body reads but lacks the account-route concurrent-reader limit. Its transport difference matches the intended production patch; this comparison supplies behavioral context, not introduction ownership. (extensions/feishu/src/monitor.transport.ts:457, b8e2dbc7ca42)
  • Latest release comparison: The transport at the supplied v2026.9.3 release commit likewise enters body reading without concurrent-reader admission. The release blob was inspected through GitHub REST after local blob retrieval failed. (extensions/feishu/src/monitor.transport.ts, 1391f7cd2d40)
  • Recorded production transport proof: The supplied body snapshot, sourceRevision d68c44c5502797567da86dd293b6c866de51bfc956527310434649e734058996, records real TCP requests through monitorWebhook at f00aebc: 64 held bodies, prompt overflow 429 with connection closure, 64 unsigned completions returning 401, and signed recovery returning 200. A separate stalled-dispatch control demonstrates released pre-auth capacity. Dispatch is instrumented; this does not claim live Feishu delivery. (extensions/feishu/src/monitor.webhook-security.test.ts:430, f00aebcbada8)
  • Proof continuity and prior finding: REST inspection of the earlier reviewed transport confirms the same admission and pre-dispatch release sequence remains in the integrated head. The earlier finding about holding capacity through dispatch is fixed. Local historical diff/blame inspection encountered unavailable blobs; no line-introduction attribution is claimed. (extensions/feishu/src/monitor.transport.ts:522, f00aebcbada8)
  • Explicit overload acceptance: The assigned reviewer Patrick-Erichsen approved the integrated head subject to CI and expressly accepted the 64-reader bound and overload 429 tradeoff. This resolves the previous review’s capacity-policy concern. (c98ed1040e28)

Likely related people:

  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Agustin Rivera: 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 (4 earlier review cycles)
  • reviewed 2026-09-03T10:08:34.054Z sha e3a34ed :: blocked before merge. :: [P2] Release the pre-auth slot before event dispatch
  • reviewed 2026-09-03T11:08:32.504Z sha f00aebc :: blocked before merge. :: none
  • reviewed 2026-09-08T13:55:44.342Z sha f00aebc :: blocked before merge. :: none
  • reviewed 2026-09-11T00:08:42.448Z sha f00aebc :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@roboclaw-bot roboclaw-bot added the clawtributor-review Clawtributor pull request awaiting prioritized maintainer review label Sep 8, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Preparing this PR for maintainer landing at f00aebcbada845d45d60f52e954666c647bd1dd5. Please refresh the completed review for the native landing gate; existing exact-head behavior evidence is in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Patrick-Erichsen Patrick-Erichsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for landing once integrated-head CI passes at c98ed1040e28bf33c7a7efbe6533daaa2cf5083c. The signed merge retains contributor ancestry and both the route-local pre-auth limiter and current-main signed-timestamp checks. Independent review of the resolved two-file delta and fresh autoreview found no actionable defects. Existing real-TCP RED/GREEN, recovery and stalled-dispatch controls are retained; the new CI run must validate their integration: https://github.com/openclaw/openclaw/actions/runs/34545481411 . A fresh local Testbox request stopped before allocation because Blacksmith was signed out, so no additional remote execution is claimed. The intended 64-reader bound and overload 429 tradeoff are accepted in this scoped fix.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 11, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit 04644af into openclaw:main Sep 11, 2026
105 of 106 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
* fix(feishu): bound pre-auth webhook reads

* fix(feishu): release pre-auth slots before dispatch
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: feishu Channel integration: feishu clawtributor-review Clawtributor pull request awaiting prioritized maintainer review 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: M 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.

3 participants