Legal

Security Controls

Aligned with SOC 2 Type II trust service criteria (Security, Availability, Confidentiality).


Access Control

  • Super-admin routes require checkIsSuperAdmin() plus a separate rate-limit layer (see admin notes).
  • RBAC roles: VIEWER, EDITOR, ADMIN, OWNER - enforced server-side on every request.
  • Session validation runs in proxy.ts, the middleware entry point.
  • Principle of least privilege: API routes expose only the data the caller's role permits.

Secrets Management

  • All secrets are stored as environment variables; none are committed to source control.
  • BYOK (Bring Your Own Key) API keys are encrypted at rest using AES-256-GCM before storage (lib/crypto/).
  • Encryption keys are stored separately from encrypted data.
  • Platform API keys (OpenAI, ElevenLabs, etc.) are accessed only server-side.

Transport Security

  • All traffic is served over TLS 1.2+ (enforced by Vercel and Railway).
  • Internal service communication (Next.js → worker) uses authenticated requests (an HMAC bearer).
  • Cloudflare R2 audio files are accessed via signed URLs with short expiry (15 minutes).

Input Validation

  • All API request bodies are validated with Zod schemas before processing.
  • URL inputs from users are validated through lib/validateUrl.ts to prevent SSRF.
  • Admin endpoints apply stricter validation against VALID_PLANS and schema constants.

Rate Limiting

  • Per-user rate limits applied on all mutating API routes.
  • Admin routes apply tighter per-admin rate limits keyed by clerkId.
  • Rate-limit responses include Retry-After headers.

Audit Logging

  • All super-admin actions are recorded in the append-only AuditLog table.
  • Logs capture: actor, action type, target resource, timestamp, and request metadata.
  • Retention: 24 months, removed by the daily cleanup job (see DATA-RETENTION.md).

Vulnerability Management

  • Dependabot or equivalent keeps dependencies updated.
  • Security reports are triaged within 5 business days.
  • Critical/high CVEs are patched within 30 days of a viable fix being available.

Incident Response

  1. Detect - Sentry alerts, log anomalies, or external report.
  2. Contain - Revoke affected sessions, disable compromised keys.
  3. Assess - Determine scope, data categories, and affected users.
  4. Notify - Follow GDPR 72-hour rule if personal data is involved (see GDPR.md).
  5. Remediate - Deploy fix, rotate secrets, audit trail updated.
  6. Review - Post-incident write-up within 5 business days.

Penetration Testing

Scheduled annually (minimum). Critical findings are treated as P0 and resolved before the next release. Reports are stored in reports/ and reviewed by the engineering lead.