Skip to content

fix(telegram): support group user allowlist (salvages #17686)#17748

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-4ecd32fd
Apr 30, 2026
Merged

fix(telegram): support group user allowlist (salvages #17686)#17748
teknium1 merged 2 commits into
mainfrom
hermes/hermes-4ecd32fd

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages #17686 (@xandersbell) onto current main, adds a backward-compat shim for pre-#17686 configs, and documents the new split.

Summary

Telegram groups now support sender-user-ID gating (TELEGRAM_GROUP_ALLOWED_USERS) and chat-ID gating (TELEGRAM_GROUP_ALLOWED_CHATS) as orthogonal allowlists. Closes the security gap in #7651 — previously any Telegram user could add the bot to a group and @mention it.

Changes

  • fix(telegram): support group user allowlist #17686 (@xandersbell, preserved): wires telegram.allow_from / group_allow_from / group_allowed_chats YAML → env vars; splits group allowlist into user vs chat maps in GatewayRunner._is_user_authorized().
  • Added on top: backward-compat shim for pre-fix(telegram): support group user allowlist #17686 configs. PR feat: allow Telegram chat allowlists for groups and forums #15027 (5 days ago) shipped TELEGRAM_GROUP_ALLOWED_USERS as a chat-ID allowlist. Without a shim, users on that guidance would silently start rejecting group traffic. Values starting with - in TELEGRAM_GROUP_ALLOWED_USERS are now honored as chat IDs and a one-shot deprecation warning points at TELEGRAM_GROUP_ALLOWED_CHATS.
  • Added on top: docs. Rewrote website/docs/user-guide/messaging/telegram.md group allowlist section to document the user/chat split with a migration block. Updated website/docs/reference/environment-variables.md. Removed the stale /thread_id suffix claim in the old docs (the code never parsed it).

Validation

scripts/run_tests.sh tests/gateway/test_telegram_group_gating.py \
                     tests/gateway/test_unauthorized_dm_behavior.py \
                     tests/gateway/test_allowlist_startup_check.py \
                     tests/gateway/test_telegram_approval_buttons.py
55 passed in 1.12s

Closes #7651.
Replaces #17686.

xandersbell and others added 2 commits April 29, 2026 21:04
PR #15027 (5 days ago) shipped TELEGRAM_GROUP_ALLOWED_USERS as a chat-ID
allowlist. #17686 correctly renames that to sender user IDs and moves
chat IDs to TELEGRAM_GROUP_ALLOWED_CHATS. Without a shim, any user on
PR #15027's guidance would silently start rejecting group traffic on
upgrade.

- gateway/run.py: in _is_user_authorized, if TELEGRAM_GROUP_ALLOWED_USERS
  contains values starting with '-' (chat-ID-shaped), honor them as chat
  IDs and log a one-shot deprecation warning pointing users at the new
  TELEGRAM_GROUP_ALLOWED_CHATS var.
- tests/gateway/test_unauthorized_dm_behavior.py: three new tests cover
  legacy chat-ID values authorizing the listed chat, not crossing to
  other chats, and mixed sender/chat values in the same var.
- website/docs/user-guide/messaging/telegram.md: rewrite the Group
  Allowlisting section to document the new user/chat split + migration
  note. Remove stale '/thread_id' suffix claim (code never parsed it).
- website/docs/reference/environment-variables.md: document all three
  Telegram allowlist env vars.
@teknium1 teknium1 merged commit 763aadd into main Apr 30, 2026
12 of 13 checks passed
@teknium1 teknium1 deleted the hermes/hermes-4ecd32fd branch April 30, 2026 04:07
@alt-glitch alt-glitch added comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/telegram Telegram bot adapter type/security Security vulnerability or hardening labels Apr 30, 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/telegram Telegram bot adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: Missing user-level access control — any user can trigger bot via @mention in any group

3 participants