Skip to content

Security: production-guards batch — consolidates the six mechanical #279 fixes #384

Description

@field123

Batches the six remaining mechanical fixes from security PRD #279 into one branch/PR. Supersedes #281, #283, #284, #285, #286, #287 (closed pointing here). Design finalized 2026-08-04 — recorded in docs/adr/0001-single-origin-trust-list.md and the package CONTEXT.md ("Session & security" terms); detail in this issue's comments.

Design (resolved)

  • Production signal: NODE_ENV === "production", no opt-out. Previews are held to production standards.
  • Guard timing: guards throw at factory construction, skipped when NEXT_PHASE === "phase-production-build" so build-once/inject-env-at-runtime pipelines still build. Fallback if NEXT_PHASE proves unreliable: first-request throw.
  • One origin list (ADR-0001): better-auth's trustedOrigins is the single origin trust list. The proxy derives its CORS allowlist from it; the allowedOrigins option is deleted (no alias). Wildcard entries honored with better-auth's pattern semantics (matcher implemented in-package). This dissolves MEDIUM-1's insecure default and structurally fixes the silent cart-id-persistence 403 from Studio origins.

Checklist

Release

Breaking (allowedOrigins removed; prod guards throw). Lands first in the #384#282#288 sequence; publish once as 0.2.0 after #288 with one consolidated migration section. No deprecation aliases — no external consumers yet.

Out of scope

HIGH-3 #282 (separate breaking PR, re-scoped there) · #288 README security model (must document the gate + SameSite=Lax, no-CSRF-token composition) · secret splitting · logger abstraction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions