Skip to content

fix(discord): gate tool targets by channel allowlist - #58450

Closed
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/discord-tool-target-allowlist
Closed

fix(discord): gate tool targets by channel allowlist#58450
ooiuuii wants to merge 1 commit into
NousResearch:mainfrom
ooiuuii:fix/discord-tool-target-allowlist

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #58449.

Summary

  • add a runtime target-policy check before Discord REST tool calls are dispatched
  • block channel-targeted actions when channel_id is outside DISCORD_ALLOWED_CHANNELS
  • block ignored channels even when explicitly targeted
  • require wildcard/no channel allowlist for guild-wide metadata reads that cannot be constrained to one channel

Proof

  • DISCORD_ALLOWED_CHANNELS=11 + discord_core(action=fetch_messages, channel_id=99) returns an error and does not call _discord_request
  • DISCORD_ALLOWED_CHANNELS=11 + discord_admin_handler(action=list_channels, guild_id=111) returns an error and does not call _discord_request
  • DISCORD_ALLOWED_CHANNELS=* keeps guild-wide reads working

Tests

  • TEMP=./.tmp/pytest TMP=./.tmp/pytest ./.venv/Scripts/python.exe -m pytest tests/tools/test_discord_tool.py -q -> 95 passed
  • ./.venv/Scripts/python.exe -m py_compile tools/discord_tool.py tests/tools/test_discord_tool.py
  • git diff --check

@alt-glitch alt-glitch added type/security Security vulnerability or hardening platform/discord Discord bot adapter area/auth Authentication, OAuth, credential pools P3 Low — cosmetic, nice to have labels Jul 4, 2026
@teknium1

teknium1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the careful work here — the implementation is clean and the tests are good. Closing on scope rather than quality grounds.

The discord/discord_admin toolsets this PR hardens are not exposed to agents in any default platform bundle — they're a vestigial surface that never took root as a design direction, and we don't currently plan to grow a policy-enforcement layer around them. Bug fixes to the tool itself are still welcome (your #54747 read-cap fix was salvaged and merged for exactly that reason), but adding a new runtime authorization subsystem to an unexposed toolset is more maintenance surface than we want to carry.

The underlying concern (channel allowlist enforcement) is real for the live gateway adapter, and the related config-vs-env allowlist issue (#32263) is on our radar for the gateway-side auth cluster.

Appreciate the continued hardening contributions — the other three in this batch (#54747, #54969, #55209) are all being merged with your authorship preserved.

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 P3 Low — cosmetic, nice to have platform/discord Discord bot adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discord tools can read outside DISCORD_ALLOWED_CHANNELS

3 participants