Skip to content

fix(feishu): gate url_verification challenge on verification_token (salvage #29663)#31465

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f9dd4507
May 24, 2026
Merged

fix(feishu): gate url_verification challenge on verification_token (salvage #29663)#31465
teknium1 merged 1 commit into
mainfrom
hermes/hermes-f9dd4507

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #29663 by @m0n3r0 onto current main.

Summary

When FEISHU_VERIFICATION_TOKEN is configured, an unauthenticated remote could previously prove endpoint control by sending a url_verification payload with any attacker-controlled challenge string — the handler reflected the challenge before the token check ran. Reorder so the token check gates the challenge response.

Changes

  • gateway/platforms/feishu.py: move url_verification echo to AFTER the verification token check
  • tests/gateway/test_feishu.py: regression test for wrong-token + stale-fixture fix on test_connect_webhook_mode_starts_local_server (fix(feishu): require webhook auth secret and honor config extras #30746 made FEISHU_VERIFICATION_TOKEN required in webhook mode; the existing fixture didn't set one and broke when that PR landed)
  • website/docs/user-guide/messaging/feishu.md: call out the gating

Salvage scope

The original PR also added _webhook_requires_secret() that only required webhook secrets when bind-host was 0.0.0.0/:: — that would have weakened #30746's stricter "webhook mode always requires a secret" guard. Dropped that change and the corresponding test. Docs around env vars in #29663 already merged via #30746.

Test plan

pytest tests/gateway/test_feishu.py -k 'webhook or url_verification'  # 15 passed

Co-authored-by: m0n3r0 34853915+m0n3r0@users.noreply.github.com

Closes #29663

…cation challenge

When FEISHU_VERIFICATION_TOKEN is configured, an unauthenticated remote
could previously prove endpoint control by sending a url_verification
payload with any attacker-controlled challenge string — the handler
reflected the challenge BEFORE running the token check.

Move the verification_token check ahead of the url_verification echo so
the challenge response is gated on a valid token. Add a regression test
covering the wrong-token case. Also fix the stale
test_connect_webhook_mode_starts_local_server fixture to set
FEISHU_VERIFICATION_TOKEN (post #30746 webhook mode requires a secret).

Salvaged from PR #29663 by @m0n3r0 — kept the url_verification reorder
and its regression test; dropped the host-conditional weakening of the
#30746 secret guard (we want webhook secrets required regardless of
bind host, not only on 0.0.0.0/::).

Docs updated to call out the gating.

Co-authored-by: teknium1 <127238744+teknium1@users.noreply.github.com>
@teknium1 teknium1 merged commit f378f00 into main May 24, 2026
20 of 23 checks passed
@teknium1 teknium1 deleted the hermes/hermes-f9dd4507 branch May 24, 2026 11:51
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-f9dd4507 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9077 on HEAD, 9077 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4834 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P1 High — major feature broken, no workaround platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/feishu Feishu / Lark adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants