Skip to content

Commit a7b8260

Browse files
author
Miriad
committed
fix: close CRON_SECRET fail-open auth in check-renders + sponsor-outreach
When CRON_SECRET env var is undefined, the auth check compared against 'Bearer undefined' — an attacker could bypass auth by sending that header. Now checks !cronSecret first and returns 503 if not configured, matching the pattern already applied to check-research and ingest routes.
1 parent 50d3731 commit a7b8260

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/api/cron/check-renders/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,13 @@ async function handleStuckDocs(client: SanityClient): Promise<{ audioGen: number
527527
*/
528528
export async function GET(request: NextRequest) {
529529
// Auth check
530+
const cronSecret = process.env.CRON_SECRET;
531+
if (!cronSecret) {
532+
console.error('[PIPELINE] CRON_SECRET not configured');
533+
return Response.json({ error: 'Server misconfigured' }, { status: 503 });
534+
}
530535
const authHeader = request.headers.get('authorization');
531-
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
536+
if (authHeader !== `Bearer ${cronSecret}`) {
532537
console.error('[PIPELINE] Unauthorized cron request');
533538
return Response.json({ error: 'Unauthorized' }, { status: 401 });
534539
}

app/api/cron/sponsor-outreach/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ const COOLDOWN_DAYS = 14
1111

1212
export async function POST(request: Request) {
1313
// Auth: Bearer token check against CRON_SECRET
14+
const cronSecret = process.env.CRON_SECRET;
15+
if (!cronSecret) {
16+
console.error('[SPONSOR] CRON_SECRET not configured');
17+
return new Response('Server misconfigured', { status: 503 });
18+
}
1419
const authHeader = request.headers.get('authorization')
15-
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
20+
if (authHeader !== `Bearer ${cronSecret}`) {
1621
console.error('[SPONSOR] Outreach cron: unauthorized request')
1722
return new Response('Unauthorized', { status: 401 })
1823
}

0 commit comments

Comments
 (0)