Skip to content

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

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-00ce2d28
Apr 30, 2026
Merged

fix(gateway): enforce auth check in busy-session path to prevent unauthorized injection (#17775)#17920
teknium1 merged 1 commit into
mainfrom
hermes/hermes-00ce2d28

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #17816 by @Bartok9 onto current main.

Closes #17775.

Summary

Adds the missing _is_user_authorized() gate at the top of _handle_active_session_busy_message(), closing a P0 authorization bypass in shared-thread contexts (Slack/Telegram/Discord with thread_sessions_per_user=False, the default).

Root cause

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 the check entirely. Non-allowlisted users in the same thread as an authorized user could queue text into _pending_messages, trigger agent.interrupt() with their content, receive a public ⚡ Interrupting... ack, and end up addressed by name in the LLM reply.

Bypass commands (/stop, /new, /approve, etc.) were already safe — they route through _message_handler which hits the cold-path auth gate. The gap was exactly the busy/interrupt fallthrough.

Changes

  • gateway/run.py: 16-line auth gate at the top of _handle_active_session_busy_message — log warning, return True (handled = silently dropped).
  • tests/gateway/test_busy_session_auth_bypass.py: 4 new cases — unauthorized dropped, authorized still processed, unauthorized blocked during drain, unauthorized can't steer.

Validation

Before After
Intruder in shared thread queued + interrupted + acked + addressed by name dropped silently
Authorized user processed normally processed normally
Tests 15/15 busy-ack pass 19/19 pass (4 new + 15 existing)

Also ran all adjacent gateway auth suites: 41/41 pass across test_allowlist_startup_check, test_auth_fallback, test_discord_bot_auth_bypass, test_unauthorized_dm_behavior.

E2E reproduced the bypass on main and confirmed the fix blocks it — intruder → no queue, no interrupt, no ack; authorized user → unchanged.

Credit to @Bartok9 for the report-to-fix workflow and test coverage.

…thorized injection (#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 #17775
@teknium1 teknium1 merged commit fbb3775 into main Apr 30, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-00ce2d28 branch April 30, 2026 11:29
@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 labels Apr 30, 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 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