07 / SECURITY & PRIVACY

Security & Local-First Architecture

1. Zero-Upload Browser Tools & Offline iPhone Core

Capturing stamped parts, solving 2D/3D strain, running Tryout Delta, and exporting PPAP PDFs or FEA meshes all run locally on your iPhone with zero network required. Every utility under /tools and /verify runs strictly inside browser memory via the File API, Canvas 2D, raw WebGL2, and Web Crypto. Zero third-party analytics pixels, ad trackers, or external font CDNs are loaded.

2. Strict Zero-Photo Cloud Sync Boundary

Stamping part photographs and unreleased vehicle panels are sensitive industrial IP. When you opt into a free account for cross-device sync, mStrain serializes an explicit allowlisted DTO containing only derived measurement coordinates, strain metrics, project metadata, custom FLCs, and optional exported reports. Raw camera frames, EXIF/GPS data, local file paths, BYOK API keys, and free-text chat logs are never uploaded.

3. Cloudflare Edge, Auth & Storage Isolation

  • Zone & transport hardening: Strict TLS 1.2+, Always Use HTTPS, HSTS, DNSSEC, workers.dev and preview URLs disabled, and strict Content-Security-Policy (object-src 'none', frame-ancestors 'none'), X-Content-Type-Options: nosniff, and Referrer-Policy: no-referrer across static and API responses.
  • Web session & CSRF defence: Web sessions use opaque SHA-256 hashed tokens in __Host-mstrain_session (HttpOnly; Secure; SameSite=Lax) with an active epoch check, paired with HMAC-signed X-CSRF-Token verification and strict Origin checks on every mutating request. One-time email sign-in links carry tokens in URL fragments (#magic=) scrubbed before verification and protected by Cloudflare Turnstile and Durable Object rate limits.
  • Native iOS auth & token rotation: Sign in with Apple (OIDC JWKS + nonce verified) and 6-digit Email OTP issue short-lived Bearer access tokens in RAM and single-use rotating refresh tokens stored in local iOS Keychain (WhenUnlockedThisDeviceOnly, never iCloud-synced). Replaying a spent refresh token immediately revokes the entire token family.
  • Ownership-scoped D1 & private R2: Every folder, project, tryout run, custom FLC, and share link enforces composite (user_id, id) keys checked against the authenticated session owner on every query. The R2 bucket has public r2.dev access disabled and streams exclusively through the authenticated Worker.
  • Revocable, passcode-protected share links: Links under /r/:token are unindexed (noindex, nofollow, noarchive), time-bounded (24h–30d), optionally gated by a salted scrypt + server-peppered 6-digit passcode with brute-force lockout, support OEM part-number redaction, and become 404 on the very next request when revoked.
  • Zero-training Forming AI limits: Built-in free Workspace AI operates on numeric-only forming briefs with strict domain guards and per-user + global Durable Object Neuron caps.
  • Export & permanent deletion: Export all workspace data as JSON or permanently delete your account (bumping auth epoch, revoking Apple tokens per TN3194 when configured, cascading D1 rows, revoking active shares, and purging R2 artifacts) at any time from /w Settings or iOS Settings.

4. Contact & Responsible Disclosure

Report suspected security vulnerabilities or privacy requests directly to info@mstrain.app.