fix(security): enforce guild allowlist for DMs - #12
Open
minto-dane wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
guild_id == Nonemessages unconditionally, which lets Discord direct messages bypass a configured guild allowlist while the bot subscribes toGatewayIntents::DIRECT_MESSAGES.OO_ALLOW_GUILD_IDSbehave as an actual allowlist boundary so DMs are not implicitly considered allowed when an allowlist is in effect.Description
TrustedCore::allow_guildto treatguild_id == Noneas allowed only whenruntime.allow_guild_idsis empty by returningself.runtime.allow_guild_ids.is_empty()for theNonecase.deny_guild_idsstill blocks listed guilds and an emptyallow_guild_idskeeps previous permissive behavior.allowlist_blocks_direct_messages_without_guildthat verifies a message withguild_id: Noneis suppressed withSuppressReason::GuildDeniedwhenallow_guild_idsis non-empty.Testing
cargo fmt, which completed successfully.cargo test allowlist_blocks_direct_messages_without_guild, but the run was blocked when thelindera-ipadicbuild script failed to download dictionary assets and the test suite could not complete.cargo test --no-default-features allowlist_blocks_direct_messages_without_guildto avoid the asset download, but it was also blocked by the samelindera-ipadicasset download failure.Codex Task