fix(gateway): enforce auth check in busy-session path to prevent unauthorized injection (#17775)#17816
Closed
Bartok9 wants to merge 1 commit into
Closed
fix(gateway): enforce auth check in busy-session path to prevent unauthorized injection (#17775)#17816Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
…thorized injection (NousResearch#17775) The busy-session handler (_handle_active_session_busy_message) bypassed the authorization gate that the cold path enforces via _is_user_authorized(). In shared-thread contexts (Slack threads, Telegram forum topics, Discord threads) where thread_sessions_per_user=False (the default), all participants share one session_key. An unauthorized user posting in the same thread as an authorized user would hit the active-session branch, skip the auth check, and have their text merged into _pending_messages or injected via agent.interrupt(). This commit adds the same _is_user_authorized() check at the top of the busy handler, before any message queuing, steering, or interrupt logic. Unauthorized messages are silently dropped (return True) with a warning log — matching the cold-path behavior. Affected platforms: Slack, Telegram, Discord, any adapter with shared-session thread contexts. Closes NousResearch#17775
Contributor
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.
Summary
Adds the missing
_is_user_authorized()gate at the top of_handle_active_session_busy_message(), closing an authorization bypass in shared-thread contexts.Problem
When
thread_sessions_per_user=False(the default), all participants in a Slack thread / Telegram forum topic / Discord thread share onesession_key. The cold path (_handle_message) correctly calls_is_user_authorized()before creating a session, but the busy path — reached when an active session already exists — skipped this check entirely.This allowed unauthorized users to:
_pending_messages(queued as the next user turn)agent.interrupt()with their contentConfirmed in production (Slack, v2026.4.23).
Fix
A single authorization check at the entry point of
_handle_active_session_busy_message(), before any queueing, steering, or interrupt logic:This mirrors the cold-path gate and uses the same source of truth (per-platform allowlists, group allowlists, pairing store, allow-all flags).
Tests
Added
tests/gateway/test_busy_session_auth_bypass.pywith 4 focused test cases:All existing
test_busy_session_ack.pytests (15) continue to pass.Severity
P0 security — cross-user session contamination with confirmed real-world exploitation.
Closes #17775