docs/security/SECURITY.md

Security Policy

Security Model

  • Clerk handles user authentication in the TanStack Start application.
  • Convex functions derive server-side authorization from the authenticated Convex identity. Client-provided user identifiers must not be trusted for access decisions.
  • Public client portal queries must return explicit client-safe projections rather than raw project, file, user, or team records.
  • Internal notes, uploader IDs, team data, private assets, reference files, and other internal metadata must not be included in public portal responses.
  • The application configures baseline response headers including frame, content-type, referrer, and browser-permission restrictions.

These controls describe the current implementation. They are not a claim of certification, regulatory compliance, or a formal security audit.

Client Portal Protection

Client portals are public bearer links. Editors can additionally require a PIN or password, disable the link, set an expiry, or regenerate its token.

  • Portal passwords are optional. Existing and newly created portals remain unprotected until an editor enables protection.
  • Passwords are derived with PBKDF2-SHA-256 using a random 16-byte salt and 120,000 iterations.
  • Convex stores only the derived hash, salt, and iteration count. Plaintext passwords are never written to the database.
  • Hash material is excluded from editor and public query responses. Editors can only see whether protection is enabled.
  • getByToken first fetches the matching clientPortals row so portalAccessState can check publication and expiry and portalPasswordMatches can verify passwordHash, passwordSalt, and passwordIterations. If verification fails, it returns only { access: "locked" }; it does not query portalDeliverables, call visibleProjectDeliverables, or query portalRevisions or portalEvents until access is granted.
  • Missing and incorrect credentials use the same locked response. Public revision submissions use the same password, enabled, and expiry checks.
  • Removing protection deletes the stored hash, salt, and iteration count.
  • The browser keeps an entered credential only in component memory for the current page session. It is not placed in the URL or browser storage.

Portal links and their passwords are still shared secrets. Use expiry and token regeneration when access should end, and avoid reusing account passwords as portal credentials.

Threat Model

Used by the security scan profile screen-gd threat-modeled security scan; findings are tagged with the component names below, so keep them stable. Last reviewed with the owner on 2026-10-30.

System overview and trust boundaries

TanStack Start app (apps/web/src) served from Vercel/Cloudflare Workers, Convex realtime backend (apps/web/convex), Clerk authentication and billing, Cloudflare R2 for files (convex/r2.ts), optional BYOK AI providers (convex/aiCredentials.ts, encrypted with AI_BYOK_ENCRYPTION_KEY). Marketing site in apps/website.

Boundaries: browser <-> Convex functions (identity from Convex auth, never client-provided IDs, per SECURITY.md); Convex <-> Clerk webhooks (convex/http.ts /api/clerk-billing, svix signature); Convex <-> R2 (presigned URLs); Convex <-> AI providers (workspace-bound encrypted keys); public client portals (convex/projectPortals.ts, bearer-token links with optional PBKDF2 password).

Components

  • Relay web app: apps/web/src (routes, workspace pages, client-hub, client-portal routes), apps/web/security-headers.mjs.
  • Relay Convex backend: apps/web/convex/* (projects, team, salary plans, earnings, revision rounds, workspace subscriptions, crons, migrations).
  • Relay client portal: convex/projectPortals.ts, convex/clientHub.ts, src/routes/client-portal, src/routes/client-hub.tsx.
  • Relay file storage: convex/r2.ts, convex/r2Settings.ts, convex/projectFiles.ts, convex/stageAssets.ts, /api/stage-assets/upload, /api/project-files/upload.
  • Relay AI features: convex/aiCredentials.ts, aiGeneration.ts, aiRuns.ts, assistantChat*, briefImport*, earningsQa*, riskDigest*.
  • Relay auth and billing: convex/auth.config.ts, convex/http.ts (Clerk billing webhook), billing*, workspaceSubscription*, creatorTrials.ts.
  • Relay website: apps/website (static marketing, waitlist). Out of scope for security scans.

Entry points and who reaches them

  • Authenticated Convex queries/mutations/actions: workspace members (owner, team seats).
  • Public portal routes and getByToken: anyone holding a portal link (client, or whoever obtained the link).
  • HTTP actions: upload endpoints (authenticated), Clerk billing webhook (Clerk, signature-verified), waitlist.
  • Crons and internal actions: Convex scheduler only.

Assets

  • Client files and media versions in R2 (confidential client work).
  • Earnings, salary contracts, invoices (financial data).
  • BYOK AI provider keys (encrypted at rest).
  • Workspace/team membership and subscription state (billing authorization).
  • Clerk identities; portal tokens and password hashes.

Attackers

  • Anonymous internet user hitting public portals, uploads, webhooks.
  • Portal link holder trying to reach non-portal data or other projects.
  • Authenticated workspace member escalating across workspaces or seats (IDOR on Convex IDs).
  • Compromised third-party (Clerk webhook spoofing, AI provider returning hostile content).

Existing controls (see above)

Server-derived identity in Convex; client-safe projections for portals; PBKDF2-SHA-256 portal passwords, same locked response for missing/incorrect; CSP and baseline headers (security-headers.mjs); svix webhook verification; no live OAuth/Stripe collection yet (THIRD_PARTY_INTEGRATION_REVIEW.md).

Out of scope

  • Marketing site (apps/website) is out of scope.

Reporting A Vulnerability

Please report suspected vulnerabilities privately through the repository's GitHub security reporting interface. If private vulnerability reporting is unavailable, contact the repository owner privately through their GitHub profile.

Include:

  • A description of the issue and its potential impact.
  • Reproduction steps or a minimal proof of concept.
  • The affected route, Convex function, or workflow.
  • Any suggested mitigation, if known.

Do not include secrets, personal data, client files, or active exploit details in a public issue. Please allow the repository owner time to investigate before public disclosure.