Skip to content

fix: authorize allowlisted WhatsApp group chats - #55875

Open
mgonto wants to merge 1 commit into
NousResearch:mainfrom
mgonto:gonto/wa-group-authz-fix
Open

fix: authorize allowlisted WhatsApp group chats#55875
mgonto wants to merge 1 commit into
NousResearch:mainfrom
mgonto:gonto/wa-group-authz-fix

Conversation

@mgonto

@mgonto mgonto commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • authorize WhatsApp group messages by chat-scoped group_policy: allowlist / group_allow_from
  • keep DM allowlists scoped to DMs so WHATSAPP_ALLOWED_USERS no longer blocks members of an explicitly allowed group
  • add regression coverage for group allowlists alongside DM allowlists

Tests

  • scripts/run_tests.sh tests/gateway/test_config_driven_access_policy.py tests/gateway/test_relay_upstream_authz.py tests/gateway/test_whatsapp_group_gating.py -v --tb=short
  • git diff --check HEAD~1..HEAD

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jun 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #53623 (broader WhatsApp group-authz + owner-detection PR, same gateway/authz_mixin.py) and #43929 (group allowlist in the Node bridge). This PR is the narrow group-allowlist subset of #53623's scope — competing OPEN approaches, flagging for a maintainer to pick narrow-vs-broad.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the WhatsApp group-vs-DM allowlist case; current gateway/authz_mixin.py:459-605 still denies that scenario, so the regression is valuable.

Problems

  • gateway/authz_mixin.py:211 and :214 on this PR use the default self.adapters registry without source.profile. Current main deliberately resolves inbound authorization through _authorization_adapter(platform, source.profile) and fails closed for missing secondary-profile adapters (gateway/authz_mixin.py:34-59). The new early allow path must use that resolver or a secondary profile could inherit the default profile's allowed WhatsApp group.
  • The added test (tests/gateway/test_config_driven_access_policy.py:292) covers only the default adapter. It does not exercise the profile-isolation path introduced on main by bb304b491.

Suggested changes

  • Salvage the narrow early group-chat authorization check using _adapter_for_source(source) and profile-aware policy lookup, then add a secondary-profile regression with differing group allowlists.

Automated hermes-sweeper review.

Comment thread gateway/authz_mixin.py
if not self._adapter_enforces_own_access_policy(source.platform):
return False

adapters = getattr(self, "adapters", None) or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main resolves authorization through the source's profile-specific adapter and fails closed when that adapter is absent (_authorization_adapter). This direct default-registry lookup can authorize a secondary-profile WhatsApp event with the default profile's group allowlist; resolve from source.profile instead.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
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 comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants