#20921: WhatsApp: enforce allowFrom for explicit outbound sends
size: S
Cluster:
WhatsApp Pairing Enhancements
## Summary
- Fixes #20108 by enforcing WhatsApp `allowFrom` for direct-message outbound targets in all modes, including `mode: "explicit"`.
- Keeps group JID behavior unchanged (`@g.us` targets still follow the group-policy path).
- Adds regression tests for explicit/custom mode deny+allow behavior.
## Why this is treated as a bug (not a feature)
- Main outbound send paths use `mode: "explicit"`.
- Previous resolver logic enforced `allowFrom` only for `implicit`/`heartbeat`, then returned success for explicit non-group targets.
- This created a path where non-allowlisted WhatsApp numbers could be targeted despite configured allowlist controls.
## Why this is the simplest fix
- Single resolver-logic correction in one file.
- No new config surface, no API change, no routing refactor.
- Existing semantics are preserved for:
- `allowFrom: ["*"]`
- empty allowlist behavior
- group JID handling
## Open question
This PR applies the minimal safe default and treats explicit-mode bypass as a security bug.
If maintainers confirm prior explicit bypass had intentional product semantics for specific workflows, a follow-up can introduce an explicit opt-in config rather than a hidden bypass.
## Validation
Reproduction input:
- `to = "+15551112222"`
- `allowFrom = ["+15550000000"]`
- `mode = "explicit"`
Observed behavior:
- Before (commit `6a19654c4`): allowed
- With this PR: blocked
Tests:
- `src/whatsapp/resolve-outbound-target.test.ts`
- `src/infra/outbound/outbound.test.ts`
## Prompt summary
I asked Codex to:
1. "fix this issue"
2. explain why this is a bug and not a feature
3. explain why this is the simplest valid fix
4. keep PR framing explicit that prior logic may have had reasons and should be confirmed in review
## Attribution
This PR is Codex-assisted, based on my prompts and review direction.
Most Similar PRs
#21889: fix(whatsapp): include outbound DMs in agent context for allowed co...
by mactsk · 2026-02-20
72.9%
#22106: fix(whatsapp): honor selfChatMode override for group mentions
by sportclaw · 2026-02-20
72.3%
#4402: fix: store group messages from non-allowlisted senders as pending c...
by adam91holt · 2026-01-30
71.0%
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
70.6%
#23685: fix(whatsapp): restore selfChatMode config usage in access control
by ekson73 · 2026-02-22
70.3%
#21893: fix(web): enforce sendPolicy on WhatsApp auto-reply delivery path
by hydro13 · 2026-02-20
69.5%
#23251: fix(whatsapp): include LID in implicit mention detection for group ...
by SidQin-cyber · 2026-02-22
69.0%
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
68.9%
#19757: fix(security): OC-91 enforce JID allowlist validation in WhatsApp s...
by aether-ai-agent · 2026-02-18
68.8%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
68.7%