Skip to content

fix(remote-connect): require pairing before IM bots accept a chat - #3879

Merged
bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:bob/fix-bot-pairing-gate
Nov 12, 2026
Merged

bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:bob/fix-bot-pairing-gate

Conversation

@bobleer

@bobleer bobleer commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Require a chat to be paired before the Feishu, Telegram and WeChat bots act on it.

On main, the message, image and file paths use states.entry(chat).or_insert_with(...) with paired = true, so once the bot loop runs, an unknown chat is treated as paired and can run commands. Outbound paths could also create state for an unpaired chat, and wrong pairing codes were not throttled.

  • New pairing_gate decides what an unpaired chat may do (welcome, pairing code entry) and rate-limits wrong codes.
  • chat_is_paired never creates state; every inbound and outbound path checks it before addressing a chat.
  • A valid code moves the connection to the chat that presents it.
  • Legacy persisted paired chats are restored as paired.
  • Platform API seams (*Platform traits) let the adapters be tested without network.

Type and Areas

Type: bug fix (security)

Areas: assembly core (remote connect IM bots)

Motivation / Impact

Closes an authorization hole in IM bot remote control. Existing paired chats keep working after upgrade.

Verification

  • cargo test --locked -p openbitfun-core --no-default-features --features remote-connect --lib service::remote_connect::bot (111 passed), including per-bot tests for refusing unknown chats after the first pairing, outbound paths never creating state, wrong-code limits, and legacy persisted pairing restore.

Remote scenarios: IM bot remote control, exercised with scripted platform fakes only, not against live Feishu/Telegram/WeChat.

Reviewer Notes

AI-assisted change, lightly tested as listed above. Behavior change: a valid pairing code now re-binds the bot to the chat that presented it.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Feishu, Telegram and WeChat bots created chat state as paired for any chat
that reached the message loop, so an unknown chat could run commands after
the first pairing. Authorization now requires the chat's own paired state,
outbound paths never create state, wrong pairing codes are rate limited, and
legacy persisted paired chats are restored.
@bobleer
bobleer merged commit 28baa4c into openBitFun:main Nov 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant