Skip to content

fix(gateway): enforce auth check in busy-session path to prevent unauthorized injection (#17775)#17816

Closed
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/17775-busy-path-auth-bypass
Closed

fix(gateway): enforce auth check in busy-session path to prevent unauthorized injection (#17775)#17816
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/17775-busy-path-auth-bypass

Conversation

@Bartok9

@Bartok9 Bartok9 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

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 one session_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:

  • Inject text into _pending_messages (queued as the next user turn)
  • Trigger agent.interrupt() with their content
  • Receive public acknowledgment ("⚡ Interrupting current task...")
  • Be directly addressed by the bot in subsequent responses

Confirmed 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:

if not self._is_user_authorized(event.source):
    logger.warning(...)
    return True  # silently dropped

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.py with 4 focused test cases:

  • Unauthorized user dropped silently (no queue, no interrupt, no ack)
  • Authorized user still processed normally
  • Unauthorized user blocked even during drain mode
  • Unauthorized user cannot steer an active agent

All existing test_busy_session_ack.py tests (15) continue to pass.

Severity

P0 security — cross-user session contamination with confirmed real-world exploitation.

Closes #17775

…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
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P0 Critical — data loss, security, crash loop comp/gateway Gateway runner, session dispatch, delivery area/auth Authentication, OAuth, credential pools labels Apr 30, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #17920 — your commit was cherry-picked onto current main with authorship preserved via rebase-merge (commit fbb3775). Clean P0 security fix and solid test coverage — thanks @Bartok9!

@teknium1 teknium1 closed this Apr 30, 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 P0 Critical — data loss, security, crash loop type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Active-session busy path bypasses user authorization in shared threads (Slack/Telegram/Discord)

3 participants