Logan is designed to handle sensitive data including WhatsApp messages, group metadata, and API credentials. This document outlines security best practices for deploying and maintaining Logan.
NEVER commit your .env file to version control.
All sensitive credentials must be stored in .env:
SUPABASE_URLandSUPABASE_KEY- Database accessGROQ_API_KEY- AI model accessANTHROPIC_API_KEY- Claude API for summariesELEVENLABS_API_KEY- Voice synthesis (if used)API_KEY- Your API server authentication keyBOT_PHONE_NUMBER- Bot's WhatsApp numberSPAM_WHITELIST- Exempt phone numbers
Generate a secure API key:
openssl rand -hex 32The auth_info/ directory contains your WhatsApp session credentials. This directory must NEVER be committed or shared.
- If leaked, anyone can impersonate your bot
- Rotate credentials by deleting
auth_info/and re-scanning QR - Back up
auth_info/securely (encrypted, offline)
Your Supabase tables should have RLS enabled:
-- Enable RLS on messages table
ALTER TABLE messages ENABLE ROW LEVEL SECURITY;
-- Create policy for authenticated access only
CREATE POLICY "Authenticated users can read messages"
ON messages FOR SELECT
USING (auth.role() = 'authenticated');- Use anon key for client-side access (limited permissions)
- Use service role key for server-side operations (full permissions)
- Never expose service role key in client code
Logan includes an API server (src/api.ts). Always enable authentication in production:
API_KEY=your-secure-random-key-hereWithout API_KEY, anyone can:
- Send messages via your bot
- Access broadcast endpoints
- Trigger operations
Built-in rate limits protect against abuse:
- 3 responses per user per minute
- Groq API: 200K tokens/day (monitor usage)
- WhatsApp: Conservative delays prevent bans
When enabling spam detection:
- Whitelist trusted users:
SPAM_WHITELIST=972501234567,972509876543 - Bot must be admin in groups (to remove spammers)
- Review spam logs regularly
Supabase automatic backups:
- Free tier: Daily backups, 7-day retention
- Pro tier: Point-in-time recovery
Manual backup:
# Export Supabase database
pg_dump -h db.your-project.supabase.co \
-U postgres -d postgres > backup.sql- Keep
.envin.gitignore - Use test API keys when possible
- Don't share
auth_info/
- Rotate all API keys before deploying
- Enable Supabase RLS policies
- Set strong API_KEY for the API server
- Use environment variables (never hardcode secrets)
- Monitor logs for suspicious activity
If using Cloudflare tunnel for remote access:
- Protect tunnel with Cloudflare Access policies
- Require authentication for sensitive endpoints
- Enable rate limiting
Logan logs all group messages to Supabase:
- Content: Full message text and media metadata
- Metadata: Sender, timestamp, group ID
- Retention: No automatic deletion (implement your own policy)
If operating in EU or with EU users:
- Inform group members about logging
- Provide data deletion mechanisms
- Document data retention policies
- Implement user opt-out
- Don't log messages containing credit cards, passwords, or PII
- Implement content filters if needed
- Consider encrypting sensitive fields in Supabase
-
Immediately rotate all affected keys:
- Groq: console.groq.com → API Keys → Revoke
- Anthropic: console.anthropic.com → API Keys → Delete
- Supabase: Dashboard → Settings → API → Reset keys
- ElevenLabs: elevenlabs.io → Profile → Regenerate
-
Check API usage logs for unauthorized access
-
Update
.envwith new keys -
Restart the bot
- Delete
auth_info/directory - Unlink device from WhatsApp → Linked Devices
- Re-scan QR code to create new session
- Check message logs for unauthorized messages
- Rotate Supabase keys immediately
- Review RLS policies
- Check for unauthorized access in Supabase logs
- Audit database contents for malicious modifications
If you discover a security vulnerability:
- Do NOT open a public GitHub issue
- Email: [your-security-email@example.com]
- Provide details: affected component, reproduction steps, impact
- Allow 90 days for patching before public disclosure
Before deploying to production:
- All secrets in
.env(not hardcoded) -
.envandauth_info/in.gitignore - Strong
API_KEYgenerated (32+ characters) - Supabase RLS policies enabled
- Rate limiting configured
- Logs monitored regularly
- Backup strategy in place
- Incident response plan documented
- Principle of Least Privilege: Grant minimal necessary permissions
- Defense in Depth: Multiple layers of security (API key + RLS + rate limiting)
- Regular Audits: Review logs, permissions, and access patterns monthly
- Keep Dependencies Updated:
npm auditand update regularly - Monitor API Usage: Watch for unusual spikes (potential abuse)
Check for vulnerabilities:
# Audit npm packages
npm audit
# Fix vulnerabilities
npm audit fix
# Check for outdated packages
npm outdated