fix: remove spoofable user-agent fallback in documentation drift auth#1601
Conversation
|
Someone is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe documentation drift internal endpoint's authentication fallback is hardened. When ChangesProduction Fallback Authentication
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎉 Thanks for your contribution, @Akshita-2307!Your PR has passed our automated GSSoC quality checks. Here's a quick summary:
A maintainer will review your PR soon. Please be patient and available for feedback. 💪 GSSoC'26 automation · Maintainer: @nisshchayarathi |
1 similar comment
🎉 Thanks for your contribution, @Akshita-2307!Your PR has passed our automated GSSoC quality checks. Here's a quick summary:
A maintainer will review your PR soon. Please be patient and available for feedback. 💪 GSSoC'26 automation · Maintainer: @nisshchayarathi |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/api/internal/documentation-drift/route.ts (1)
38-40: ⚡ Quick winConsider using a generic error message to avoid configuration disclosure.
The explicit message "ANALYSIS_RUNNER_SECRET not configured" confirms to potential attackers that the secret environment variable is missing. Since this is an internal endpoint that shouldn't be exposed, a generic "Unauthorized" message is safer—log the specific reason server-side instead.
🔒 Proposed fix
if (process.env.NODE_ENV === "production") { + console.error("[DocumentationDrift] ANALYSIS_RUNNER_SECRET not configured in production"); - return NextResponse.json({ error: "Unauthorized - ANALYSIS_RUNNER_SECRET not configured" }, { status: 401 }); + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); }🤖 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 `@app/api/internal/documentation-drift/route.ts` around lines 38 - 40, The response in the NODE_ENV production check currently returns a detailed message revealing "ANALYSIS_RUNNER_SECRET not configured"; change the HTTP response in that conditional (the NextResponse.json return) to a generic message such as { error: "Unauthorized" } with status 401, and move the detailed reason into a server-side log (use your existing logger or console.error) so the specific missing-config detail is not sent to clients; update the conditional around process.env.NODE_ENV and the NextResponse.json return in route.ts accordingly and add a server-side log entry explaining the missing ANALYSIS_RUNNER_SECRET.
🤖 Prompt for all review comments with 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.
Nitpick comments:
In `@app/api/internal/documentation-drift/route.ts`:
- Around line 38-40: The response in the NODE_ENV production check currently
returns a detailed message revealing "ANALYSIS_RUNNER_SECRET not configured";
change the HTTP response in that conditional (the NextResponse.json return) to a
generic message such as { error: "Unauthorized" } with status 401, and move the
detailed reason into a server-side log (use your existing logger or
console.error) so the specific missing-config detail is not sent to clients;
update the conditional around process.env.NODE_ENV and the NextResponse.json
return in route.ts accordingly and add a server-side log entry explaining the
missing ANALYSIS_RUNNER_SECRET.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8487d626-e4a6-467d-8145-cd9224040dc8
📒 Files selected for processing (1)
app/api/internal/documentation-drift/route.ts
The documentation drift internal endpoint fell back to checking user-agent for 'vercel-cron' when ANALYSIS_RUNNER_SECRET was not configured. User-agent headers are caller-controlled and easily spoofed. Now rejects all requests in production when the secret is missing.
Closes #1541
Summary by CodeRabbit