Skip to content

Require WhatsApp callback authentication#99

Merged
pmbstyle merged 1 commit into
mainfrom
codex/fix-unauthenticated-whatsapp-inbound-endpoint
May 17, 2026
Merged

Require WhatsApp callback authentication#99
pmbstyle merged 1 commit into
mainfrom
codex/fix-unauthenticated-whatsapp-inbound-endpoint

Conversation

@pmbstyle
Copy link
Copy Markdown
Owner

Motivation

  • The WhatsApp inbound route accepted requests when the configured callback token was empty, allowing unauthenticated clients to submit attacker-controlled sender and text payloads that could drive the agent runtime.
  • The default configuration and examples left the callback token blank, making the endpoint network-reachable and exploitable by default.

Description

  • Require a non-empty callback token in register_whatsapp_routes before accepting inbound payloads and validate every request using secrets.compare_digest to prevent bypasses via an empty token.
  • Add _ensure_callback_token to WhatsAppRuntime and call it from WhatsAppRuntime.start() to generate an ephemeral token with secrets.token_urlsafe(32) when no stable token is configured, and log a warning recommending configuration for persistence.
  • Add regression tests that assert the inbound route rejects when the runtime token is missing and that the runtime generates a token prior to bridge startup in tests/test_whatsapp_bridge_routes.py and tests/test_whatsapp_runtime.py.
  • Minor import/formatting adjustments to keep code consistent with project tooling.

Testing

  • Ran formatting and lint checks with uv run black --check and uv run ruff check on the modified files and they passed.
  • Executed the FastAPI route/runtime smoke script (uv run python - <<'PY' ... PY) that verifies route behavior and runtime token generation and it succeeded.
  • Ran the unit tests tests/test_whatsapp_bridge_routes.py and tests/test_whatsapp_runtime.py under the project PYTHONPATH with pytest and all tests passed (12 passed, 16 warnings).

Codex Task

@pmbstyle pmbstyle self-assigned this May 17, 2026
@pmbstyle pmbstyle merged commit 3af8c9a into main May 17, 2026
4 checks passed
@pmbstyle pmbstyle deleted the codex/fix-unauthenticated-whatsapp-inbound-endpoint branch May 17, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant