Skip to content

fix(telegram): defense-in-depth — enforce TELEGRAM_ALLOWED_USERS at adapter level (#23778)#28492

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704
May 19, 2026
Merged

fix(telegram): defense-in-depth — enforce TELEGRAM_ALLOWED_USERS at adapter level (#23778)#28492
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #23795 (@ygd58).

Summary

Defense-in-depth fix for #23778. The gateway runner's _is_user_authorized already gates inbound messages, but the platform adapter's _should_process_message (the earliest gate per message) did NOT check the allowlist — only callbacks did. This adds a uniform check at the adapter level so unauthorized messages are dropped before they even enter the gateway-runner dispatch flow.

This pairs with the (still-pending) #24468 salvage which fixes the fail-OPEN default in _is_callback_user_authorized when TELEGRAM_ALLOWED_USERS is empty.

Changes

  • gateway/platforms/telegram.py::_should_process_message: check _is_callback_user_authorized for the sender; drop with warning if unauthorized.

Validation

  • scripts/run_tests.sh tests/gateway/test_telegram_group_gating.py tests/gateway/test_telegram_mention_boundaries.py -q → 36/36 passing.

Authorship preserved via cherry-pick.

…ssages

TELEGRAM_ALLOWED_USERS was only checked for callback/inline-button
actions but not for inbound messages. Unauthorized users triggered an
'Unauthorized user' log warning but their messages were still processed
by the agent — a P0 security bypass (issue #23778).

Fix: add allowlist check in _should_process_message() which is called
for all message types (text, command, media, location). If the sender
is not in TELEGRAM_ALLOWED_USERS, the message is dropped immediately
with a warning log. Empty TELEGRAM_ALLOWED_USERS continues to allow
all users (existing behavior).

Fixes #23778
@teknium1 teknium1 merged commit db50af9 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-6063e704 branch May 19, 2026 05:06
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-6063e704 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: 8888 on HEAD, 8888 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4653 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 comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 19, 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.

3 participants