Threat model
Our primary threats, in order:
- Prompt injection / jailbreak leading to answer leakage.
- Cross-user data exposure via RLS misconfiguration.
- Content-blind design failure (educator/parent seeing student content).
- Credential theft (service-role keys, Stripe secrets, Anthropic keys).
- Denial of service (Anthropic bill exhaustion, DB flooding).
Every mitigation below maps to one or more of these.
Authentication
- Passwordless magic-link and Google OAuth via Supabase Auth. Optional email/password.
- Session cookies are httpOnly + Secure + SameSite=Lax.
- Session rotation on sign-in from a new device.
- Parental consent workflow for under-18 users, with signed one-time tokens.
Authorization
- Row-Level Security (RLS) enabled on every user-owned Postgres table. Enforced in the database, not the app.
- Educator and parent dashboards have deliberately-absent SELECT policies on any table containing student content (messages, explain_backs, recall_cards, uploads).
- Service-role usage restricted by ESLint rule to specific escape hatches (cron jobs, Stripe webhook, uploads, leak-events writer).
- Cross-user access tested in an automated Vitest RLS suite (30+ assertions per launch).
AI safety
- Two-layer leak guard: regex heuristic + Haiku cross-reference on every tutor reply that has a known answer.
- Automatic regeneration in “STRICT MODE” on first leak; template refusal on second.
- Jailbreak sanitizer strips common injection patterns before the tutor receives user text.
- Leak events stored redacted (numbers, quoted strings, and known-answer substrings replaced with tokens) with 90-day retention.
- Automated adversarial Prompt QA runs before each release (5 patterns × N problems, must return zero leaks).
Data protection
- All transport encrypted (TLS 1.2+; HSTS with 2-year max-age + preload).
- All storage encrypted at rest via Supabase (AES-256).
- Anthropic prompts sent under zero-retention API terms (not used for training).
- Student content never logged. Structured logs contain user IDs, session IDs, request IDs, durations, error class + message; automatic redaction of email addresses and token-shaped values.
Abuse + cost protection
- Per-user daily token cap (varies by plan: free 20k, student/family/sprint 200k, institution 60-120k).
- Per-user + per-IP rate limits via Upstash Redis token buckets.
- Circuit breaker on Anthropic client (5 fails / 60s → 30s open → half-open).
- Hard monthly spend cap on Anthropic account.
Perimeter
- Content Security Policy locked down to specific allowlisted domains (no wildcards for script-src or connect-src).
- X-Frame-Options: DENY. X-Content-Type-Options: nosniff. Restrictive Referrer-Policy.
- Permissions-Policy: camera, microphone, geolocation, and interest-cohort explicitly disabled.
- Stripe webhook signature verification on every event.
- Cron endpoints require a bearer
CRON_SECRET.
Observability
/api/health— DB liveness check.- Client-side error sink at
/api/errors(rate-limited by IP). - Cron heartbeat table (
cron_run_log) for run-history visibility. - PostHog product analytics + session replay (with sensitive-input masking).
- External uptime monitor pinging
/api/health.
Compliance posture
- COPPA: parental consent required for under-13 with verifiable email confirmation.
- GDPR-K: parental consent required for under-16 in EU jurisdictions.
- FERPA: institutional deployments position Brainback as a “school official.” DPA available.
- PIPEDA + Loi 25 (Québec): Canadian data-protection laws respected; disclosure to third parties limited to sub-processors listed at /legal/subprocessors.
- SOC 2 Type I: not yet certified. Targeting completion within 12 months of institutional pilot maturity.
Breach notification
If we discover a Personal Data breach, we’ll notify affected users and institutional customers within 72 hours per §12 of our DPA.
Responsible disclosure
Report security issues to brainback@stratosync.solutions with subject “SECURITY:”. We commit to:
- Acknowledge within 24 hours.
- Initial assessment within 72 hours.
- Do not pursue legal action against good-faith researchers.
- Public credit on request.