Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const env = createEnv({
OIDC_CLIENT_ID: z.string().optional(),
OIDC_CLIENT_SECRET: z.string().optional(),
OIDC_WELL_KNOWN_URL: z.string().optional(),
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: z.boolean().optional(),
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: z.boolean().default(false),
UPLOAD_MAX_FILE_SIZE_MB: z.coerce.number().int().positive().default(10),
},

Expand Down Expand Up @@ -139,7 +139,9 @@ export const env = createEnv({
OIDC_CLIENT_ID: process.env.OIDC_CLIENT_ID,
OIDC_CLIENT_SECRET: process.env.OIDC_CLIENT_SECRET,
OIDC_WELL_KNOWN_URL: process.env.OIDC_WELL_KNOWN_URL,
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: Boolean(process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING),
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: Boolean(
JSON.parse(process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING || 'false'),
),
Comment on lines +142 to +144

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Require an exact JSON boolean before enabling account linking.

Boolean(JSON.parse(...)) converts non-boolean JSON values to booleans. For example, 1, the JSON string "false", and {} become true. This can enable allowDangerousEmailAccountLinking in src/server/auth.ts with an invalid configuration value.

Parse the JSON value without Boolean(...) and let z.boolean() reject non-boolean values.

Proposed fix
-    OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: Boolean(
-      JSON.parse(process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING || 'false'),
-    ),
+    OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: JSON.parse(
+      process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING || 'false',
+    ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: Boolean(
JSON.parse(process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING || 'false'),
),
OIDC_ALLOW_DANGEROUS_EMAIL_LINKING: JSON.parse(
process.env.OIDC_ALLOW_DANGEROUS_EMAIL_LINKING || 'false',
),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/env.ts` around lines 142 - 144, Update OIDC_ALLOW_DANGEROUS_EMAIL_LINKING
to pass the parsed JSON value directly instead of wrapping it with Boolean(...),
allowing the existing z.boolean() validation to reject non-boolean configuration
values while preserving the false default.

UPLOAD_MAX_FILE_SIZE_MB: process.env.UPLOAD_MAX_FILE_SIZE_MB
? Number(process.env.UPLOAD_MAX_FILE_SIZE_MB)
: 10,
Expand Down
Loading