Skip to content

Commit d446c94

Browse files
FuturMixclaude
andauthored
fix: remove hardcoded session secret fallback (#20)
SESSION_SECRET falls back to 'dev-secret-change-me' when the env var is not set. This means a production deployment without the env var uses a predictable HMAC key, allowing anyone to forge session cookies. Replace the fallback with a startup check that throws if the env var is missing. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d5eec9e commit d446c94

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

apps/web/lib/auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import 'server-only';
22
import { cookies } from 'next/headers';
33

44
const COOKIE = 'cp_session';
5-
const SESSION_SECRET = process.env.SESSION_SECRET ?? 'dev-secret-change-me';
5+
const SESSION_SECRET = process.env.SESSION_SECRET;
6+
if (!SESSION_SECRET) {
7+
throw new Error('SESSION_SECRET environment variable is required');
8+
}
69
const enc = new TextEncoder();
710

811
async function hmac(data: string): Promise<string> {

0 commit comments

Comments
 (0)