Fix/jwt hardcoded secret#383
Conversation
|
@HassanKorey Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Heads up on the CI failures: Run Tests: Fails on the new Check production config secrets step because GitHub Actions doesn't pass repository secrets to fork PRs. The check is working exactly as intended, but it's restricted by the fork environment. |
We had a PR that broke the contracts, but that has been fixed; just sync your branch, and the contract failures will be gone. But the Next.js failures are yours to fix. |
Pull Request Template
Description
Closes #351
This PR addresses the token forgery vulnerability by removing the insecure
NEXTAUTH_SECRETfallback and deleting the legacy, vulnerable session route that blindly trusted cookies.What Changed:
app/lib/jwt.ts: Removed the hardcoded secret fallback. The module now throws an error on import ifNEXTAUTH_SECRETis missing, ensuring the app "fails fast at startup".app/app/(auth)/session/route.ts: Completely deleted the deprecated endpoint.token/auth-tokencookie extraction path fromgetTokenFromRequestand cleaned up theauth-tokenclearing logic inlogout/route.ts.jwt-config.test.tsto test the new fail-fast behavior and updatedauth.test.tsto match the deleted routes/cookies..github/workflows/test.ymlto explicitly check forNEXTAUTH_SECRETin production config secrets.(Security Note: This completely closes the legacy token forgery path. Developers must now provide a valid
NEXTAUTH_SECRETenvironment variable for the application to start or build successfully).Checklist
npx prisma generateafter schema changesnpx prisma migrate devornpx prisma migrate deployas appropriatePost-Merge Steps for Maintainers
If this PR includes changes to the Prisma schema:
(N/A - No Prisma schema changes in this PR)
Run the following command to apply the migration to your database: