Skip to content

fix(telegram): honor group user allowlists - #55496

Open
itsflownium wants to merge 1 commit into
NousResearch:mainfrom
itsflownium:fix/telegram-group-allowlist-55462
Open

fix(telegram): honor group user allowlists#55496
itsflownium wants to merge 1 commit into
NousResearch:mainfrom
itsflownium:fix/telegram-group-allowlist-55462

Conversation

@itsflownium

Copy link
Copy Markdown
Contributor

Summary

  • Let Telegram group-scoped user allowlists authorize supergroup/forum senders even when a DM-wide allow_from list is configured.
  • Keep group_allowed_chats chat-scoped so it does not widen a sender allowlist by itself.
  • Accept allowed_users and group_allowed_users config aliases and bridge them to the existing auth variables.

Problem
Telegram intake auth checked config allow_from before the gateway auth resolver. If the owner was in allow_from, an additional supergroup user listed in TELEGRAM_GROUP_ALLOWED_USERS or group_allow_from could be rejected before the group-scoped allowlist was considered. Users also tried allowed_users / group_allowed_users in config.yaml, but those names were not bridged.

Validation

  • $HOME/.hermes/hermes-agent/venv/bin/python -m pytest -q tests/gateway/test_telegram_auth_check.py tests/gateway/test_telegram_group_gating.py
  • $HOME/.hermes/hermes-agent/venv/bin/python -m ruff check plugins/platforms/telegram/adapter.py gateway/config.py tests/gateway/test_telegram_auth_check.py tests/gateway/test_telegram_group_gating.py
  • $HOME/.hermes/hermes-agent/venv/bin/python -m py_compile plugins/platforms/telegram/adapter.py gateway/config.py tests/gateway/test_telegram_auth_check.py tests/gateway/test_telegram_group_gating.py

Refs #55462

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter area/auth Authentication, OAuth, credential pools sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jun 30, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the group/forum intake short-circuit. Current main still returns directly from the adapter-level allow_from check at plugins/platforms/telegram/adapter.py:861-865, before the gateway's scoped group-user resolution at gateway/authz_mixin.py:458-566 can run.

Problems

  • plugins/platforms/telegram/adapter.py:693 changes explicit empty-list behavior. Current main tests allow_from is not None, so allow_from: [] rejects all senders at intake. The new helper returns an empty set for both a missing key and an explicit empty value, then if adapter_allow_from: treats both as absent. Preserve configured-vs-empty state so the change remains fail-closed.

Suggested changes

  • Retain allowlist-key presence separately from normalized values and add regressions for explicit empty allow_from and group-scoped allowlists.

Automated hermes-sweeper review.

)
adapter_group_allowed_chats = self._telegram_config_allowlist("group_allowed_chats")

if adapter_allow_from:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This truthiness check collapses an explicit allow_from: [] into “no configured allowlist.” Before this PR, the is not None check rejected every sender for that explicit empty list. Preserve key presence separately and add a regression so empty lists remain fail-closed.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants