Skip to content

[SECURITY] WhatsApp self-chat mode responds to ALL incoming messages (empty allowlist = allow everyone) #8389

@sahilthakur456111-stack

Description


[SECURITY] WhatsApp self-chat mode responds to ALL incoming messages (empty allowlist = allow everyone)

## Security Issue

**Severity:** Medium-High
**Component:** WhatsApp Bridge

### Description
In `self-chat` mode (default), the bridge processes messages from ANY sender. Anyone who messages the user triggers a Hermes response.

### Root Cause
Two issues compound:

1. **`allowlist.js` line 67-68** — Empty allowlist returns `true`:
```javascript
if (!allowedUsers || allowedUsers.size === 0) {
  return true; // ← everyone allowed!
}
  1. bridge.js line 231 — No mode distinction for non-fromMe messages:
if (!msg.key.fromMe && !matchesAllowedUser(senderId, ALLOWED_USERS, SESSION_DIR)) {
  continue;
}

WHATSAPP_ALLOWED_USERS defaults to empty → everyone passes.

Impact

Any person messaging the user gets a pairing code reply. Affects ALL users without explicit allowlist config.

Fix

In bridge.js, add mode-aware filtering:

if (!msg.key.fromMe) {
  if (WHATSAPP_MODE === 'self-chat') {
    continue; // Self-chat: never respond to other people
  }
  if (!matchesAllowedUser(senderId, ALLOWED_USERS, SESSION_DIR)) {
    continue;
  }
}

And in allowlist.js, change empty allowlist default to return false.


---

For the PR, fork it, create a branch, apply those two changes, and submit. Want me to prepare the exact diff you can paste?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical — data loss, security, crash loopcomp/gatewayGateway runner, session dispatch, deliveryplatform/whatsappWhatsApp Business adaptertype/securitySecurity vulnerability or hardening

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions