Security Model

Defense-in-depth across setup credentials, revocable device tokens, WebSocket auth, HTTP headers, and audit logging.

Authentication & Credential Lifecycle

  • One-time setup key (SYNORA_API_KEY): Generated as 32 random bytes (64 hex chars) via openssl rand -hex 32 during installation and stored with mode 0600 in .env. Used only when creating a vault (POST /api/vaults) and discarded by the client immediately afterward.
  • Per-device bearer tokens (syn_dev_...): Each device receives its own high-entropy token (32 random bytes base64url-encoded). The server compares using constant-time equality for setup keys and stores only SHA-256(token) for device tokens.
  • Instant device revocation: Revoking a device via Settings → Synora (or POST /api/devices/:deviceId/revoke) sets revokedAt, closes any active WebSocket for that device with code 4001 (device_revoked), invalidates unused pairing codes created by it, and rejects future API requests.

Transport & WebSocket Security

  • No tokens in URL query strings: server/src/ws.js authenticates /ws via the Authorization: Bearer ... header or an initial { "type": "auth", "token": "..." } message within a 5-second timeout. Tokens are never passed in WebSocket query parameters where proxy or tunnel logs could capture them.
  • Security headers on every response:
    • X-Content-Type-Options: nosniff
    • Referrer-Policy: no-referrer
    • Cache-Control: no-store (on all /api/* responses)
  • Log redaction: Fastify logger redacts req.headers.authorization, req.headers.cookie, *.deviceToken, *.pairingCode, and *.apiKey.

Abuse Protection & Auditability

  • Sliding-window rate limiting: Both POST /api/vaults and POST /api/pair/complete enforce PairingRateLimiter (default 15 failed attempts per 60 seconds per client IP).
  • Internal database isolation: In Standard Mode, CouchDB listens only on the private synora-standard Docker bridge network; port 5984 is never bound to the host.
  • Vault audit log: Security events (vault_created, e2ee_enabled, pairing_started, pairing_completed, device_revoked) are recorded per vault and viewable via GET /api/audit and Settings → Synora → Security audit log.

Rotating the Setup Key

If you ever need to rotate SYNORA_API_KEY without affecting already-paired devices:

# 1. Generate a new 64-hex key
openssl rand -hex 32
# 2. Update SYNORA_API_KEY in deployment/lite/.env (or deployment/standard/.env)
# 3. Recreate only the api container:
cd /opt/synora/deployment/lite && sudo docker compose up -d --force-recreate api