#19757: fix(security): OC-91 enforce JID allowlist validation in WhatsApp send tools — Aether AI Agent
agents
size: XS
trusted-contributor
## Summary
- **Attack vector**: `sendReactionWhatsApp` in `src/agents/tools/whatsapp-actions.ts` accepted `chatJid` directly from agent tool parameters without validating it against the configured `allowFrom` contact list. An authenticated agent could invoke the `react` action with an arbitrary WhatsApp JID (any phone number or group JID), bypassing the allowFrom restriction entirely and sending reactions to contacts outside the operator-configured allowlist.
- **Fix applied**: Added allowlist validation in the `react` action handler using the existing `resolveWhatsAppOutboundTarget` function (from `src/whatsapp/resolve-outbound-target.ts`) with `mode: "implicit"`. The resolved (normalized) JID is passed to `sendReactionWhatsApp` instead of the raw user-supplied value. Per-account `allowFrom` config is respected, falling back to the channel-level `allowFrom`.
- **Advisory**: GHSA-2prf-9cw7-fq62
## Test plan
- [ ] Reaction to a JID in `allowFrom` succeeds as before
- [ ] Reaction to a JID not in `allowFrom` throws an error and does not call `sendReactionWhatsApp`
- [ ] Wildcard `allowFrom: ["*"]` continues to allow all targets
- [ ] Per-account `allowFrom` overrides channel-level list correctly
- [ ] Group JIDs continue to be handled by `isWhatsAppGroupJid` inside `resolveWhatsAppOutboundTarget`
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Security fix that adds allowlist (`allowFrom`) validation to the WhatsApp `react` action handler using the existing `resolveWhatsAppOutboundTarget` function. Previously, `sendReactionWhatsApp` accepted an arbitrary `chatJid` from agent tool parameters without checking the configured contact allowlist, allowing reactions to be sent to any JID.
- Correctly reuses the `resolveWhatsAppOutboundTarget` helper with `mode: "implicit"` and respects per-account vs. channel-level `allowFrom` precedence
- Uses the resolved (normalized) JID for the outbound call, which is consistent with other send paths
- **Existing tests in `whatsapp-actions.e2e.test.ts` will break**: `resolveWhatsAppOutboundTarget` normalizes `"123@s.whatsapp.net"` to `"+123"` (E.164), but all test assertions expect the original JID format — tests need to be updated
- **Missing test coverage**: no tests were added to verify the new allowlist blocking behavior (JID not in `allowFrom` throws, wildcard allows all, per-account override, etc.) despite the PR description's test plan listing these scenarios
<h3>Confidence Score: 3/5</h3>
- The security fix logic is sound but existing tests will break due to JID format change, and the new validation path lacks test coverage.
- The core security fix correctly applies allowlist validation using an existing, well-tested utility. However, the normalized JID format passed to sendReactionWhatsApp will cause all four existing e2e test assertions to fail, and the PR adds no new tests for the security validation itself. The runtime behavior is likely correct since downstream functions (toWhatsappJid) handle E.164 → JID conversion, but the test breakage and missing coverage lower confidence.
- src/agents/tools/whatsapp-actions.ts (test assertions will fail), src/agents/tools/whatsapp-actions.e2e.test.ts (needs updates for normalized JID format and new allowlist validation tests)
<sub>Last reviewed commit: 20e5a85</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
81.5%
#11611: feat: separate group-level allowlist from sender-level command auth...
by thisnick · 2026-02-08
78.6%
#4390: fix(whatsapp): allow media from allowlisted groups without groupAllow…
by Sarang19114 · 2026-01-30
78.5%
#20399: feat(whatsapp): surface inbound reaction events to agent session
by andrewchen · 2026-02-18
77.3%
#6567: fix: include paired users in WhatsApp group sender allowlist
by giannisanni · 2026-02-01
76.3%
#21889: fix(whatsapp): include outbound DMs in agent context for allowed co...
by mactsk · 2026-02-20
76.2%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
75.8%
#10196: fix(whatsapp): sanitize raw mention IDs in outbound messages
by koala73 · 2026-02-06
75.5%
#11026: fix(auto-reply): remove ctx.To from elevated authorization token set
by coygeek · 2026-02-07
75.5%
#12894: feat(whatsapp): add reaction notifications support
by ekson73 · 2026-02-09
75.2%