Skip to content

fix(security): enforce guild allowlist for DMs - #12

Open
minto-dane wants to merge 1 commit into
masterfrom
codex/fix-guild-allowlists-to-block-discord-dms
Open

fix(security): enforce guild allowlist for DMs#12
minto-dane wants to merge 1 commit into
masterfrom
codex/fix-guild-allowlists-to-block-discord-dms

Conversation

@minto-dane

Copy link
Copy Markdown
Owner

Motivation

  • The runtime allowed guild_id == None messages unconditionally, which lets Discord direct messages bypass a configured guild allowlist while the bot subscribes to GatewayIntents::DIRECT_MESSAGES.
  • The change makes OO_ALLOW_GUILD_IDS behave as an actual allowlist boundary so DMs are not implicitly considered allowed when an allowlist is in effect.

Description

  • Change TrustedCore::allow_guild to treat guild_id == None as allowed only when runtime.allow_guild_ids is empty by returning self.runtime.allow_guild_ids.is_empty() for the None case.
  • Preserve existing deny-list semantics so deny_guild_ids still blocks listed guilds and an empty allow_guild_ids keeps previous permissive behavior.
  • Add a regression test allowlist_blocks_direct_messages_without_guild that verifies a message with guild_id: None is suppressed with SuppressReason::GuildDenied when allow_guild_ids is non-empty.

Testing

  • Ran cargo fmt, which completed successfully.
  • Attempted cargo test allowlist_blocks_direct_messages_without_guild, but the run was blocked when the lindera-ipadic build script failed to download dictionary assets and the test suite could not complete.
  • Attempted cargo test --no-default-features allowlist_blocks_direct_messages_without_guild to avoid the asset download, but it was also blocked by the same lindera-ipadic asset download failure.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant