fix(gateway): fail-close Telegram auth when TELEGRAM_ALLOWED_USERS is empty; warn on ALLOW_ALL - #24667
Closed
wesleysimplicio wants to merge 1 commit into
Closed
Conversation
… empty; warn on ALLOW_ALL _is_authorized_user() returned True when TELEGRAM_ALLOWED_USERS was unset, granting any Telegram user full agent access (filesystem, terminal, GitHub). Fail closed by default: empty allowlist now returns False unless the operator explicitly sets GATEWAY_ALLOW_ALL_USERS=true or TELEGRAM_ALLOW_ALL_USERS=true. Also add a loud SECURITY WARNING log when any allow-all flag is active, so operators are aware the gateway is open. Closes NousResearch#24457 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Contributor
Author
|
Closing in favor of #24468 (earliest open) per @alt-glitch's note — same fail-closed Telegram auth fix for #24457. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
TELEGRAM_ALLOWED_USERSis not set,TelegramAdapter._is_authorized_user()returnsTrue— any Telegram account that discovers the bot gets full agent access (filesystem, terminal, GitHub credentials).Additionally, there is no warning emitted when
GATEWAY_ALLOW_ALL_USERS=trueis active — the most dangerous open state passes silently.Root cause
gateway/platforms/telegram.py:501:gateway/run.py:3360: the startup warning only fires whennot _any_allowlist and not _allow_all, so_allow_all=Trueproduces no log output.Fix
gateway/platforms/telegram.py— fail closed when no allowlist:gateway/run.py— loud warning when allow-all is active:Tests
tests/gateway/test_telegram_auth_fail_closed.py(new, 6 tests):test_no_allowlist_no_allow_all_deniesFalsetest_gateway_allow_all_permitsGATEWAY_ALLOW_ALL_USERS=true→Truetest_telegram_allow_all_permitsTELEGRAM_ALLOW_ALL_USERS=1→Truetest_allowlist_match_permitsTruetest_allowlist_mismatch_deniesFalsetest_wildcard_in_allowlist_permits_all*in CSV →TrueAll 6 pass.
Visual
flowchart TD A[_is_authorized_user called] --> B{TELEGRAM_ALLOWED_USERS set?} B -- yes --> C{user_id in allowlist or *?} C -- yes --> D[return True] C -- no --> E[return False] B -- no --> F{GATEWAY_ALLOW_ALL_USERS or TELEGRAM_ALLOW_ALL_USERS?} F -- yes --> D F -- no --> ECloses #24457