larksuite / larksuite/channel-sdk-python

webhook: signature verification silently no-ops without encrypt_key; no timestamp-freshness or replay checks

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
16
Forks
8
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Context

We run lark-channel-sdk==1.2.0 inside two FastAPI-based webhook bridges. While security-reviewing the webhook path we found that delegating request verification entirely to the SDK leaves several gaps. Reporting them here so other integrators are aware and so they can be considered for hardening — happy to provide more detail or test cases.

Observed on 1.2.0

  1. Signature verification silently no-ops when no encrypt key is configured. _verify_sign returns without checking anything if encrypt_key is unset. That may be by design (Feishu only signs when encryption is enabled), but the caller gets no signal that inbound requests are effectively unauthenticated — an integrator who reads "the SDK verifies signatures" can ship an open webhook without realizing it.
  2. No timestamp-freshness check. Even with encrypt_key configured and the signature verified, X-Lark-Request-Timestamp is never checked against a window, so an arbitrarily old (captured) request still verifies.
  3. No replay deduplication. There is no (timestamp, nonce) dedup, so a captured legitimate request can be replayed indefinitely and will pass verification every time.

Combined effect: a captured request is replayable forever, and in the no-encrypt-key configuration any forged request is accepted.

Suggestions

  • Fail loudly (or require an explicit opt-out) when webhook mode runs without an encrypt key, instead of silently skipping verification.
  • Reject timestamps outside a configurable window (we use ±300s, rejecting the exact boundary so replay-cache TTLs stay strictly positive).
  • Document that replay dedup is the integrator's responsibility, or provide a small (timestamp, nonce) cache with TTL tied to the timestamp's remaining validity.

What we did meanwhile

We now verify signature + timestamp window + replay dedup at our own boundary before the SDK sees the request, e.g. https://github.com/wz-heng/dsh-feishu-bridge (see _verify_webhook_request and its tests). Not a criticism of the SDK's scope — just flagging that today's behavior is easy to over-trust.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies _verify_sign as the no-op path and points to _verify_webhook_request plus its tests in dsh-feishu-bridge as a reference. Read those entry points first; completion requires an agreed SDK scope and tests covering the selected handling for missing keys, timestamp freshness, and replay deduplication.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.