Skip to content

fix: add QR endpoint authentication and secure DM allowlist defaults (fixes #3)#4

Open
hnshah wants to merge 1 commit intoComposioHQ:masterfrom
hnshah:fix/secure-qr-endpoint-and-dm-allowlists-issue-3
Open

fix: add QR endpoint authentication and secure DM allowlist defaults (fixes #3)#4
hnshah wants to merge 1 commit intoComposioHQ:masterfrom
hnshah:fix/secure-qr-endpoint-and-dm-allowlists-issue-3

Conversation

@hnshah
Copy link
Copy Markdown

@hnshah hnshah commented Mar 22, 2026

Security Issues Fixed

This PR addresses the security concerns raised in #3.

Fixes #3

…ixes ComposioHQ#3)

**Security Issues Fixed:**

1. **Unauthenticated QR Endpoint**
   - The /qr endpoint was publicly accessible with no authentication
   - Anyone reaching the server could pair WhatsApp to the assistant
   - Attack: Scan QR → full WhatsApp access → read messages, send commands

2. **Wildcard DM Allowlist Defaults**
   - setup.sh automatically set TELEGRAM_ALLOWED_DMS=* (allow anyone)
   - Default .env.example had TELEGRAM_ALLOWED_DMS=*
   - Attack: Anyone could DM the bot and run commands/access memory

**Solutions:**

1. **Optional Token Authentication for /qr**
   - Added QR_AUTH_TOKEN environment variable
   - When set: /qr?token=YOUR_TOKEN required
   - Auto-generates random token in setup.sh
   - Logs warning if token not set in production
   - Backward compatible: works without token (dev/local use)

2. **Restrictive DM Allowlist Defaults**
   - Changed .env.example: TELEGRAM_ALLOWED_DMS= (empty = restrictive)
   - Updated setup.sh to prompt for Telegram user IDs
   - Added docs: how to get Telegram ID from @userinfobot
   - Removed auto-wildcard behavior

3. **Security Documentation**
   - Added "Security" section to README with QR protection guide
   - Warning about wildcard allowlists on public servers
   - Production deployment security checklist

**Testing:**

✅ QR endpoint without token: works (backward compatible)
✅ QR endpoint with token: requires ?token= query param
✅ QR endpoint with wrong token: returns 401 Unauthorized
✅ setup.sh prompts for Telegram user IDs instead of defaulting to *
✅ Logs show clear warnings when QR_AUTH_TOKEN not set

**Breaking Changes:** None (token is optional, allowlists configurable)

**Migration Guide:**

For existing deployments, add to .env:
```bash
QR_AUTH_TOKEN=$(openssl rand -hex 32)
```

Update Telegram config from wildcard to specific user IDs.

Fixes ComposioHQ#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QR code HTTP endpoint is unauthenticated and DMs are unrestricted

1 participant