Skip to content

Security: Enforce fail-fast authentication on video generation API#286

Open
Krish-Makadiya wants to merge 1 commit into
knoxiboy:mainfrom
Krish-Makadiya:security/video-endpoint-auth
Open

Security: Enforce fail-fast authentication on video generation API#286
Krish-Makadiya wants to merge 1 commit into
knoxiboy:mainfrom
Krish-Makadiya:security/video-endpoint-auth

Conversation

@Krish-Makadiya
Copy link
Copy Markdown
Contributor

Description

This PR addresses a critical cost-abuse vulnerability in the video generation endpoint (/api/video/generate).

Previously, the currentUser() authentication check was positioned too late in the POST handler, allowing unauthenticated requests to bypass early validation and potentially consume server resources before being rejected.

The Clerk authentication check has now been moved to the very top of the POST handler. This ensures a fail-fast mechanism where unauthenticated requests are immediately met with a 401 Unauthorized response.

Impact

  • Security: Prevents a Denial-of-Wallet attack vector.
  • Resource Protection: Ensures expensive operations (like Groq API calls, Tesseract OCR processing, Remotion video rendering, and FFmpeg processing) can only be triggered by fully authenticated sessions.

Changes Made

  • Moved the currentUser() check to the top of the POST handler in app/api/video/generate/route.ts prior to request parsing and logic execution.

Closes #174

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@Krish-Makadiya is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added size/m gssoc'26 GSSoC program issue level:advanced Advanced level task labels May 24, 2026
@github-actions github-actions Bot requested a review from knoxiboy May 24, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc'26 GSSoC program issue level:advanced Advanced level task size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security]: Video generation endpoint lacks authentication check

1 participant