Skip to content

Harden Feishu webhook replay guards#66707

Merged
drobison00 merged 3 commits into
openclaw:mainfrom
eleqtrizit:396
Apr 14, 2026
Merged

Harden Feishu webhook replay guards#66707
drobison00 merged 3 commits into
openclaw:mainfrom
eleqtrizit:396

Conversation

@eleqtrizit

Copy link
Copy Markdown
Contributor

Summary

  • harden Feishu webhook auth and callback replay guards so they fail closed even if upstream validation drifts
  • add regression coverage for missing encrypt keys and malformed or blank callback tokens

Changes

  • make monitorWebhook reject startup without an encryptKey and fail closed in signature validation when no key is present
  • reject blank card-action tokens in handleFeishuCardAction and stop treating them as fresh dedupe claims
  • add focused Feishu tests covering transport startup, handler-level blank-token rejection, and event-layer empty-token drops

Validation

  • Ran pnpm test extensions/feishu/src/bot.card-action.test.ts extensions/feishu/src/monitor.webhook-security.test.ts extensions/feishu/src/monitor.card-action.lifecycle.test.ts
  • Ran pnpm tsgo and confirmed the remaining failures are unrelated existing issues in extensions/telegram/src/bot-handlers.runtime.ts:840 and src/infra/outbound/message-action-runner.media.test.ts:651
  • Attempted local agentic review with claude -p "/review", but it hung in this environment without producing output

Notes

  • the current tree already blocks the original report path at the monitor-account layer; this change hardens the underlying helpers so they also fail closed directly

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S maintainer Maintainer-authored PR labels Apr 14, 2026
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Hardens three Feishu security guards to fail closed: isFeishuWebhookSignatureValid now returns false (instead of true) when no encryptKey is present, monitorWebhook throws at startup if encryptKey is missing, and handleFeishuCardAction rejects blank tokens before any dedup or dispatch. Regression tests cover all three new code paths and the existing monitor-layer empty-token filter.

Confidence Score: 5/5

  • Safe to merge; all remaining findings are minor style suggestions that do not affect correctness.
  • All three security guards are correct fail-closed changes with matching test coverage. The only finding is a P2 ordering nit in card-action.ts where the blank-token check could move above the decodeFeishuCardAction call — harmless, just slightly cleaner.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/card-action.ts
Line: 186-192

Comment:
**Blank-token guard placed after `decodeFeishuCardAction` call**

The early-return guard for a missing token is inserted after `decodeFeishuCardAction({ event })` runs on line 186. Since decoding is pure/side-effect-free this isn't a correctness issue, but moving the check above the `decoded` declaration is slightly cheaper and makes the "fail fast" intent clearer to readers.

```suggestion
  const { cfg, event, runtime, accountId } = params;
  const account = resolveFeishuRuntimeAccount({ cfg, accountId });
  const log = runtime?.log ?? console.log;
  if (!event.token.trim()) {
    log(
      `feishu[${account.accountId}]: rejected card action from ${event.operator.open_id}: missing token`,
    );
    return;
  }
  const decoded = decodeFeishuCardAction({ event });
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(feishu): harden webhook replay guard..." | Re-trigger Greptile

Comment thread extensions/feishu/src/card-action.ts Outdated
Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.
@drobison00
drobison00 merged commit c8003f1 into openclaw:main Apr 14, 2026
8 checks passed
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(feishu): harden webhook replay guards

* changelog: note Feishu webhook + card-action fail-closed hardening (openclaw#66707)

* fix(feishu): move blank-token check above decodeFeishuCardAction

Run the early-return guard against a missing/blank card-action
token before decoding the card-action payload. Decoding is
side-effect-free so this is a readability + tiny-perf nit, not a
correctness change. Matches Greptile's P2 suggestion.

---------

Co-authored-by: Devin Robison <[email protected]>
@eleqtrizit
eleqtrizit deleted the 396 branch June 30, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants