diff --git a/gateway/platforms/qqbot/adapter.py b/gateway/platforms/qqbot/adapter.py index 28a297944d0..10e1f62e72c 100644 --- a/gateway/platforms/qqbot/adapter.py +++ b/gateway/platforms/qqbot/adapter.py @@ -976,6 +976,18 @@ class QQAdapter(BasePlatformAdapter): if not channel_id: return + # Apply group_policy ACL — guild channels are group-like contexts. + # Without this check any member of any guild the bot is in could + # bypass the configured allowlist. + guild_id = str(d.get("guild_id", "")) + author_id = str(author.get("id", "")) + if not self._is_group_allowed(guild_id or channel_id, author_id): + logger.debug( + "[%s] Guild message blocked by ACL: channel=%s user=%s", + self._log_tag, channel_id, author_id, + ) + return + member = d.get("member") if isinstance(d.get("member"), dict) else {} nick = str(member.get("nick", "")) or str(author.get("username", "")) @@ -1032,6 +1044,17 @@ class QQAdapter(BasePlatformAdapter): if not guild_id: return + # Apply dm_policy ACL — guild DMs were previously unauthenticated. + # Without this check any member of any guild the bot is in could + # bypass the configured allowlist via direct messages. + author_id = str(author.get("id", "")) + if not self._is_dm_allowed(author_id): + logger.debug( + "[%s] Guild DM blocked by ACL: guild=%s user=%s", + self._log_tag, guild_id, author_id, + ) + return + text = content att_result = await self._process_attachments(d.get("attachments")) image_urls = att_result["image_urls"]