Skip to content

fix(gateway/discord): require allowlist auth on slash commands [SECURITY]#19178

Merged
kshitijk4poor merged 2 commits into
mainfrom
fix/discord-slash-auth
May 3, 2026
Merged

fix(gateway/discord): require allowlist auth on slash commands [SECURITY]#19178
kshitijk4poor merged 2 commits into
mainfrom
fix/discord-slash-auth

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

SECURITY — Salvage of PR #18125 by @0xyg3n. Fixes CVSS 9.8 Critical vulnerability: Discord slash commands bypass all DISCORD_ALLOWED_* authorization gates.

Vulnerability

_run_simple_slash(), _handle_thread_create_slash(), and the /skill handler performed zero authorization checks. Every gate enforced by on_messageDISCORD_ALLOWED_USERS, DISCORD_ALLOWED_ROLES, DISCORD_ALLOWED_CHANNELS, DISCORD_IGNORED_CHANNELS — was completely bypassed for slash commands. Any guild member could execute /background (RCE via terminal tool), /restart, /model, /skill, etc.

Verified end-to-end against a real third-party deployment by the reporter.

Fix

  • _evaluate_slash_authorization() — pure logic, mirrors all 4 on_message gates with fail-closed semantics
  • _check_slash_authorization() — sends ephemeral rejection + warning log + cross-platform admin alert
  • Auth gate runs BEFORE defer() so rejections are ephemeral (not visible to channel)
  • /skill autocomplete returns [] for unauthorized users (no catalog leak via keystroke probing)
  • Component views (ExecApproval, SlashConfirm, UpdatePrompt, ModelPicker) now honor role allowlists via shared _component_check_auth() helper — previously role-only deployments had wide-open buttons
  • Optional DISCORD_HIDE_SLASH_COMMANDS defense-in-depth (hides from non-admin guild members)
  • Backwards compatible: no-allowlist deployments (single-tenant, all guild members trusted) are unaffected

Changes

From contributor (applied as single commit preserving authorship):

  • gateway/platforms/discord.py — auth gate on all slash paths, component view role support, admin alerts
  • gateway/run.py — set adapter.gateway_runner for cross-platform alert routing (3 lines)
  • tests/gateway/test_discord_slash_auth.py — 737 lines of security regression tests
  • tests/gateway/test_discord_component_auth.py — 230 lines of component auth tests
  • tests/gateway/test_discord_slash_commands.py — updated for auth-before-defer ordering

Follow-up:

  • scripts/release.py — add 0xyg3n noreply email to AUTHOR_MAP

Test results

  • 84 tests passed across slash auth, component auth, and slash commands (0 failures)

0xyg3n and others added 2 commits May 3, 2026 16:13
Slash commands (_run_simple_slash, _handle_thread_create_slash) bypassed
every DISCORD_ALLOWED_* gate enforced by on_message. Any guild member
could invoke /background (RCE via terminal), /restart, /model, /skill,
etc. CVSS 9.8 Critical.

- _evaluate_slash_authorization mirrors on_message gates (user, role,
  channel, ignored channel) with fail-closed semantics
- _check_slash_authorization sends ephemeral reject + logs + admin alert
- Auth gate runs before defer() so rejections are ephemeral
- /skill autocomplete returns [] for unauthorized users (no catalog leak)
- Component views (ExecApproval, SlashConfirm, UpdatePrompt, ModelPicker)
  now honor role allowlists via shared _component_check_auth helper
- Optional DISCORD_HIDE_SLASH_COMMANDS defense-in-depth
- Cross-platform admin alert (Telegram/Slack fallback) on unauthorized attempts

Based on PR #18125 by @0xyg3n.
@kshitijk4poor kshitijk4poor merged commit c14bf44 into main May 3, 2026
9 of 10 checks passed
@kshitijk4poor kshitijk4poor deleted the fix/discord-slash-auth branch May 3, 2026 10:44
@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 platform/discord Discord bot adapter area/auth Authentication, OAuth, credential pools labels May 3, 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 platform/discord Discord bot adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants