Skip to content

Commit 5dc174e

Browse files
committed
Validate ENCRYPTION_KEY length when parsing env vars
1 parent 18fffd1 commit 5dc174e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/webapp/app/env.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ const EnvironmentSchema = z.object({
2323
DATABASE_READ_REPLICA_URL: z.string().optional(),
2424
SESSION_SECRET: z.string(),
2525
MAGIC_LINK_SECRET: z.string(),
26-
ENCRYPTION_KEY: z.string(),
26+
ENCRYPTION_KEY: z
27+
.string()
28+
.refine(
29+
(val) => Buffer.from(val, "utf8").length === 32,
30+
"ENCRYPTION_KEY must be exactly 32 bytes"
31+
),
2732
WHITELISTED_EMAILS: z
2833
.string()
2934
.refine(isValidRegex, "WHITELISTED_EMAILS must be a valid regex.")

0 commit comments

Comments
 (0)