#11026: fix(auto-reply): remove ctx.To from elevated authorization token set
size: XS
trusted-contributor
## Fix Summary
Remove recipient identity (`ctx.To`) from the elevated allowlist check. In WhatsApp inbound DM flows, `To` is set to the bot's own number for every message, allowing any command-capable sender to bypass the elevated allowlist when the owner's number is in `allowFrom`.
Only sender-authenticated identities (`SenderName`, `SenderUsername`, `SenderTag`, `SenderE164`, `From`) should be used for authorization. Recipient fields are routing metadata, not authorization principals.
## Issue Linkage
Fixes #11022
## Security Snapshot
| Metric | Value |
|--------|-------|
| **Score** | 9.9 / 10.0 |
| **Severity** | Critical |
| **Vector** | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H |
## Implementation Details
### Files Changed
- `src/auto-reply/reply/reply-elevated.ts` (+0/-2)
### Technical Analysis
Remove recipient identity (`ctx.To`) from the elevated allowlist check. In WhatsApp inbound DM flows, `To` is set to the bot's own number for every message, allowing any command-capable sender to bypass the elevated allowlist when the owner's number is in `allowFrom`.
## Validation Evidence
- Command: `pnpm build`
- Status: passed
## Risk and Compatibility
non-breaking; compatibility impact was not explicitly documented in the original PR body.
## AI-Assisted Disclosure
- AI-assisted: yes
- Model: Claude Code
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates elevated-authorization allowlist matching to consider only sender-authenticated identities (e.g., `From`, `Sender*`) and no longer treat `ctx.To` as an authorization principal.
- Prevents a WhatsApp inbound-DM bypass where `To` is always the bot’s own number, letting any command-capable sender pass elevated checks when the owner is listed in `allowFrom`.
- Change is localized to `src/auto-reply/reply/reply-elevated.ts` and affects the token set used by `isApprovedElevatedSender`, leaving gating structure (`enabled` + `allowFrom`) intact.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change removes `ctx.To` from the elevated allowlist token set, which is a clear security-hardening fix and is narrowly scoped (2 lines removed) without altering control flow or config semantics. Review of the full file shows no remaining reliance on `ctx.To` for authorization decisions in this module.
- No files require special attention
<!-- 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
#5391: fix(commands): prevent webchat/tui from inheriting messaging channe...
by Glucksberg · 2026-01-31
76.6%
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
75.8%
#19757: fix(security): OC-91 enforce JID allowlist validation in WhatsApp s...
by aether-ai-agent · 2026-02-18
75.5%
#6567: fix: include paired users in WhatsApp group sender allowlist
by giannisanni · 2026-02-01
74.8%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
74.4%
#11611: feat: separate group-level allowlist from sender-level command auth...
by thisnick · 2026-02-08
74.0%
#17882: fix: drop WhatsApp pairing reply for unconfigured accounts
by adit-negi · 2026-02-16
73.7%
#4402: fix: store group messages from non-allowlisted senders as pending c...
by adam91holt · 2026-01-30
73.6%
#18193: fix: default elevatedDefault to 'off' instead of 'on' (#18177)
by lailoo · 2026-02-16
72.7%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
72.5%