Security [HIGH]: E2E_TEST_MODE bypass must fail-fast in production #42
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
E2E_TEST_MODE=truedisables rate-limit and session enforcement. Guard inassertSecureRuntimeEnv()throws on load, but inpackages/api/src/trpc.ts:141-144the prod+E2E check onlyconsole.warns. A single removed import would silently re-enable bypass in production.Evidence
packages/api/src/trpc.ts:141-144 — console.warn() instead of throw on prod+E2E_TEST_MODEapps/web/src/server/auth.ts:50-56 — E2E_TEST_MODE bypasses rate-limitImpact
Defense-in-depth degraded. A future refactor that drops the
assertSecureRuntimeEnv()import silently disables auth rate-limits in production.Proposed Fix
In trpc.ts replace console.warn with
throw new Error(...)orprocess.exit(1). Centralize all E2E-bypass checks inruntime-env.tsso they cannot be accidentally split.Acceptance Criteria
runtime-env.tsfunctionParent Epic: #1
Source: Full-Codebase Security Audit 2026-04-16 (A-6)
Resolved in commit
93a7fba(security: fail-fast dev-bypass flag in production). The auth bootstrap throws at startup ifE2E_TEST_MODE=1is set whileNODE_ENV=production.