Skip to content

Security: codebyellalesperance/Second-Brain-MCP

Security

SECURITY.md

πŸ”’ Security Policy

Supported Versions

Version Supported
1.0.x βœ… Yes
< 1.0 ❌ No

Security Features

Data Storage

  • βœ… Local-first - All data stored on your machine
  • βœ… No cloud sync - Nothing leaves your computer (except API calls)
  • βœ… SQLite database - Standard, auditable storage
  • βœ… File-based vectors - JSON format, human-readable

Encryption

  • βœ… AES-256-GCM - Industry standard authenticated encryption
  • βœ… PBKDF2 - Key derivation with 100,000 iterations
  • βœ… Random IV/Salt - Different for each encrypted memory
  • βœ… Secure key storage - File permissions 0o600 (owner only)

API Security

  • βœ… Optional authentication - API key via header or query parameter
  • βœ… Input validation - All inputs validated before processing
  • βœ… No SQL injection - Parameterized queries
  • βœ… CORS enabled - Can restrict origins if needed

Code Quality

  • βœ… TypeScript strict mode - Type safety
  • βœ… 83 tests - Comprehensive test coverage
  • βœ… CI/CD - Automated testing on every commit
  • βœ… No external dependencies for core encryption

API Authentication

For Local Use (Default)

No authentication required. The API is only accessible on localhost:3000.

Safe when:

  • Running on local machine only
  • Not exposing port 3000 to network
  • Only you have access to the machine

For Network/Public Exposure

Enable API authentication:

# Generate a secure API key
openssl rand -hex 32

# Add to .env
API_KEY=your-generated-key-here

# Restart API server
yarn api

Use in requests:

# Via header (recommended)
curl -H "X-API-Key: your-key" http://localhost:3000/api/memories

# Via query parameter
curl "http://localhost:3000/api/memories?api_key=your-key"

⚠️ Important:

  • Never commit API keys to git
  • Rotate keys periodically
  • Use HTTPS in production (reverse proxy with nginx/Caddy)
  • Consider IP whitelisting

Encryption Best Practices

What to Encrypt

Definitely encrypt:

  • πŸ”’ Passwords and credentials
  • πŸ”’ API keys and tokens
  • πŸ”’ Social Security Numbers
  • πŸ”’ Financial information
  • πŸ”’ Medical records
  • πŸ”’ Private conversations

Probably don't encrypt:

  • πŸ“– General preferences ("I like dark mode")
  • πŸ“– Public facts ("I work in Seattle")
  • πŸ“– Non-sensitive experiences

Trade-off: Encrypted memories cannot be searched semantically.

Key Management

Do:

  • βœ… Backup encryption key in password manager
  • βœ… Use strong passphrases (>20 characters)
  • βœ… Store key file securely
  • βœ… Never share encryption keys

Don't:

  • ❌ Commit .key file to git
  • ❌ Share encryption key via email/chat
  • ❌ Store key in plaintext notes
  • ❌ Reuse keys across systems

Reporting Security Issues

If you discover a security vulnerability:

  1. DO NOT open a public GitHub issue
  2. Email: ella@lesperance.dev (replace with your email)
  3. Include:
    • Description of vulnerability
    • Steps to reproduce
    • Potential impact
    • Suggested fix (if any)

We'll respond within 48 hours and work on a fix.

Security Checklist

For Personal Use

  • Install on personal machine only
  • Use localhost API (no network exposure)
  • Enable encryption for sensitive data
  • Regular backups (yarn cli export)
  • Optional: Set API_KEY if paranoid

For Team/Public Use

  • Set strong API_KEY
  • Use HTTPS (nginx/Caddy reverse proxy)
  • Enable CORS restrictions
  • Set up rate limiting
  • Regular security audits
  • Use separate database per user
  • Consider adding user authentication

Known Limitations

By Design

  1. No user authentication - Single user system
  2. Local storage - Not designed for multi-device sync
  3. API keys in env - Not a secrets manager
  4. In-memory cache - Cleared on restart

Mitigations

  1. Use for personal/single-user only
  2. Enable encryption for sensitive data
  3. Set API_KEY if exposing to network
  4. Regular backups
  5. Keep software updated

Environment Variable Security

Secure

# .env file (gitignored)
ENCRYPTION_KEY=...
API_KEY=...
ANTHROPIC_API_KEY=...

Less Secure

# Command line (visible in process list)
ENCRYPTION_KEY=abc123 yarn api

# Hardcoded (never do this)
const key = "my-secret-key";

Third-Party API Usage

The system makes API calls to:

  1. Anthropic (Claude) - For conversation analysis

    • Data sent: Conversation text
    • Retention: Per Anthropic privacy policy
    • Optional: Can disable by not using extract features
  2. OpenAI (Whisper) - For voice transcription

    • Data sent: Audio recordings
    • Retention: Per OpenAI privacy policy
    • Optional: Can disable by not using voice features

Privacy: If privacy is critical, don't use voice or conversation extraction features.

Secure Deployment

Local Machine (Recommended)

# Run on localhost only
PORT=3000 yarn api
# Accessible: http://localhost:3000

Exposed to Network (Advanced)

# 1. Set API key
API_KEY=$(openssl rand -hex 32)

# 2. Set up reverse proxy (nginx)
server {
  listen 443 ssl;
  server_name brain.yourdomain.com;
  
  ssl_certificate /path/to/cert.pem;
  ssl_certificate_key /path/to/key.pem;
  
  location / {
    proxy_pass http://localhost:3000;
    proxy_set_header X-Real-IP $remote_addr;
  }
}

# 3. Enable firewall
sudo ufw allow 443/tcp
sudo ufw enable

Audit Log

Currently no audit logging. Future enhancement could add:

  • Log all memory operations (add, update, delete)
  • Log failed authentication attempts
  • Log API access with timestamps
  • Rotate logs automatically
  • Alert on suspicious activity

Compliance

This software is provided as-is for personal use. For compliance requirements (GDPR, HIPAA, etc.):

  • βœ… Data stays local (GDPR right to data)
  • βœ… User controls all data (GDPR right to deletion)
  • βœ… Encryption available (data protection)
  • ❌ No audit trail (not HIPAA compliant out-of-box)
  • ❌ No multi-tenancy (not designed for organizations)

License

MIT License - See LICENSE file.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.


Last Updated: October 8, 2025
Contact: Create an issue on GitHub for security questions.

There aren’t any published security advisories