Description
SESSION_SECRET in apps/web/lib/env.ts:22 defaults to "dev-only-insecure-change-me-0000000000000000" if not explicitly set via environment variable.
Impact
If this default reaches production, session token hashes (used in hashSessionToken()) are trivially forgeable. An attacker who knows this default can craft arbitrary session cookies and impersonate any user including admins.
Location
apps/web/lib/env.ts:22:
sessionSecret: process.env.SESSION_SECRET || "dev-only-insecure-change-me-0000000000000000",
Fix
- Validate that
SESSION_SECRET is set in production at startup
- Remove the dev fallback or restrict it to development only
- Rotate all existing sessions after deploying the fix
sessionSecret: (() => {
const val = process.env.SESSION_SECRET;
if (!val && process.env.NODE_ENV === 'production') {
throw new Error('SESSION_SECRET must be set in production');
}
return val || 'dev-only-insecure-change-me-0000000000000000';
})(),
Description
SESSION_SECRETinapps/web/lib/env.ts:22defaults to"dev-only-insecure-change-me-0000000000000000"if not explicitly set via environment variable.Impact
If this default reaches production, session token hashes (used in
hashSessionToken()) are trivially forgeable. An attacker who knows this default can craft arbitrary session cookies and impersonate any user including admins.Location
apps/web/lib/env.ts:22:Fix
SESSION_SECRETis set in production at startup