fix(whatsapp): end-to-end allowlisted group intake for multi-member chats - #68844
fix(whatsapp): end-to-end allowlisted group intake for multi-member chats#68844bhargav-forsyt wants to merge 1 commit into
Conversation
…hats Wizard/.env installs configure WHATSAPP_ALLOWED_USERS and WHATSAPP_GROUP_ALLOWED_USERS, but three independent gates still dropped messages after the bridge queued them: 1. Baileys adapter only read allowlists from config.extra (empty for env-only installs), so dm_policy/group_policy=allowlist ran with an empty set and silently rejected every inbound. 2. Bridge applied the DM sender allowlist to group participants, so any non-owner member of an allowlisted support group was dropped before Python. 3. Gateway authz treated WHATSAPP_GROUP_ALLOWED_USERS as a sender list (or ignored it), so even adapter-accepted group traffic hit Unauthorized user for members not also on the DM allowlist. Also forwards owner-typed (fromMe) group messages when WHATSAPP_FORWARD_OWNER_MESSAGES is on (personal-number bot) or when mode is self-chat, so operators can talk to the agent in groups. Default OFF / empty-config deny-all semantics preserved. Explicit allow_from: [] does not widen via a stale env allowlist.
|
Thanks for tracing the full intake path. Current Problems
Suggested changes
This is an automated hermes-sweeper review. |
|
Just adding this comment for maintainers comparing this with #73465, which we opened: The current Node DM sender check is not suitable for group messages because it checks the individual participant's phone number. In an allowed group, that can reject every member who is not also on the private DM allowlist. Both PRs fix that problem, but in different ways. This PR lets group messages past the Node DM sender check and relies on the Python group policy downstream. In #73465, we replace the incorrect DM check with a group-specific check in Node using This PR also changes adapter environment loading, gateway authorization, and Posting this so maintainers can evaluate the overlapping fix and the additional changes separately. |
What does this PR do?
Fixes the full path that makes allowlisted WhatsApp groups dead for anyone who is not also on the DM allowlist — the customer-support / multi-member group use case.
A message from a non-owner group member currently dies at up to three independent gates even when
WHATSAPP_GROUP_ALLOWED_USERScontains that group's JID:_allow_from/_group_allow_fromonly readconfig.extra, never the documented env vars.env-only installs run*_policy=allowlistwith an empty set → every inbound silently dropped after the bridge queues itWHATSAPP_ALLOWED_USERS) applied to group participantsallowlist_mismatch)WHATSAPP_GROUP_ALLOWED_USERSnot wired as a chat-scoped allowlist (unlikeTELEGRAM_GROUP_ALLOWED_CHATS)Unauthorized userfor members not on the DM allowlistAlso forwards owner-typed (
fromMe) group messages whenWHATSAPP_FORWARD_OWNER_MESSAGES=true(personal-number bot) orWHATSAPP_MODE=self-chat, so operators can talk to the agent in groups. Default remains drop (from_me_group) for dedicated bot-number deployments.Why one PR (not three): each layer alone still leaves the group looking dead. Reviewers cannot validate the customer-support path without all three. Pure classifiers are unit-tested so each gate stays reviewable in isolation.
Related open PRs (partial coverage — this supersedes the E2E gap)
Happy to close or coordinate if a maintainer prefers salvaging one of the above instead.
Related Issue
Related to #7269 (group members unauthorized). Complements the WhatsApp Cloud env-allowlist salvage (#58504 / #58448) for the Baileys path.
Type of Change
Changes Made
plugins/platforms/whatsapp/adapter.py—_resolve_allow_list_source()with key-presence semantics (explicitallow_from: []stays deny-all; no silent widen via stale env). Falls back toWHATSAPP_ALLOWED_USERS/WHATSAPP_ALLOW_FROMandWHATSAPP_GROUP_ALLOWED_USERS/WHATSAPP_GROUP_ALLOW_FROM. OptionalWHATSAPP_ALLOW_ALL_USERS→*only when no config key present.gateway/authz_mixin.py— mapPlatform.WHATSAPP→WHATSAPP_GROUP_ALLOWED_USERSin both chat-allowlist maps; accept bare numeric group id or full@g.usJID.scripts/whatsapp-bridge/dm_allowlist_scope.js— pure helper: DM sender allowlist is not applied to groups.scripts/whatsapp-bridge/from_me_group_gate.js— pure helper: groupfromMeforward rules (self-chat always; bot only withWHATSAPP_FORWARD_OWNER_MESSAGES; always drop status //sendechoes).scripts/whatsapp-bridge/bridge.js— wire both helpers.test_whatsapp_baileys_allowlist_env.py,test_whatsapp_group_chat_authz.py,dm_allowlist_scope.test.mjs,from_me_group_gate.test.mjs.How to Test
cd scripts/whatsapp-bridge node --test dm_allowlist_scope.test.mjs from_me_group_gate.test.mjs allowlist.test.mjs owner_message_gate.test.mjs node --check bridge.jsWHATSAPP_MODE=botWHATSAPP_DM_POLICY=allowlist+WHATSAPP_ALLOWED_USERS=<owner phone only>WHATSAPP_GROUP_POLICY=allowlist+WHATSAPP_GROUP_ALLOWED_USERS=<group JID>WHATSAPP_FORWARD_OWNER_MESSAGES=true, owner-typed group message is processedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (targeted WhatsApp / authz suites above — 66 Python + 24 Node)Documentation & Housekeeping
docs/, docstrings) — or N/A (behavior matches already-documented env vars; no new keys)cli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ASecurity / defaults
WHATSAPP_ALLOWED_USERSallow_from: []+ stale envorchainfromMe(bot, flag off)fromMe(flag on / self-chat)Screenshots / Logs
Local validation: