Skip to content

security(whatsapp): deny unknown senders when WHATSAPP_ALLOWED_USERS is empty (#8389)#8410

Closed
draix wants to merge 1 commit into
NousResearch:mainfrom
draix:fix/8389-whatsapp-security
Closed

security(whatsapp): deny unknown senders when WHATSAPP_ALLOWED_USERS is empty (#8389)#8410
draix wants to merge 1 commit into
NousResearch:mainfrom
draix:fix/8389-whatsapp-security

Conversation

@draix

@draix draix commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

matchesAllowedUser() in scripts/whatsapp-bridge/allowlist.js returned true when the allowlist was empty, allowing any sender to trigger the agent in bot mode. This is a medium-high severity issue: anyone who messages the bot owner's WhatsApp number could interact with their Hermes agent.

Root cause

// BEFORE (vulnerable)
if (!allowedUsers || allowedUsers.size === 0) {
    return true;  // ← empty allowlist = allow everyone
}

Fix

// AFTER (secure)
if (!allowedUsers || allowedUsers.size === 0) {
    return false;  // empty allowlist = deny unknown senders
}

Impact on self-chat mode

None. In self-chat mode the bridge already filters to fromMe=true messages before calling matchesAllowedUser. Third-party senders never reach the allowlist check in self-chat, so this change does not affect the default configuration.

What you need to do

If you are running in bot mode (WHATSAPP_MODE=bot) without WHATSAPP_ALLOWED_USERS set, you now need to configure who can use the bot:

# Allow specific users
WHATSAPP_ALLOWED_USERS=+15551234567,+15559876543

# Allow everyone (opt-in)
WHATSAPP_ALLOW_ALL_USERS=true

A clear warning is now logged at startup when bot mode is active and no allowlist is configured.

Additional improvements

  • Better startup log: distinguishes self-chat vs bot mode and warns specifically when bot mode has no allowlist
  • gateway/run.py: extra warning when WhatsApp is in bot mode with no allowlist configured

Testing

14 new tests in tests/test_whatsapp_allowlist_security.py covering:

  • Empty/None/whitespace allowlist → deny (TestEmptyAllowlistDenies)
  • Correct allowlist matching with E.164, LID, JID normalization (TestAllowlistMatchesCorrectly, TestAllowlistNormalization)
  • Self-chat mode behavior is unaffected (TestSelfChatModeIsUnaffected)

Fixes #8389

@alt-glitch

Copy link
Copy Markdown
Collaborator

Note: #8431 is a duplicate PR fixing the same issue (#8389).

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P0 Critical — data loss, security, crash loop platform/whatsapp WhatsApp Business adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 28, 2026
@draix

draix commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

Cerrando este PR como superseded por #21291 (mergeado el 2026-05-07), que también cierra #8389 e implementa el mismo fix sobre scripts/whatsapp-bridge/allowlist.js + bridge.js.

Notas para futuro tracking:

Sin acción pendiente — cierro y limpio el branch.

@draix draix closed this May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P0 Critical — data loss, security, crash loop platform/whatsapp WhatsApp Business adapter type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants