fix: change logout from GET to POST with session destruction#578
fix: change logout from GET to POST with session destruction#578anshul23102 wants to merge 1 commit into
Conversation
The logout route used GET which allows CSRF attacks via image tags or link prefetching. Changed to POST and added req.session.destroy() plus res.clearCookie() to ensure the session is fully invalidated server-side and the cookie is cleared from the browser on logout. Fixes GitMetricsLab#556
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
More reviews will be available in 15 minutes and 19 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @GitMetricsLab, pinging this as part of NSoC'26. Let me know if you have any review feedback. Thanks! |
Summary
Closes #556
The
/api/auth/logoutroute was registered asGET, making it vulnerable to CSRF via image tags, link prefetching, or simple<a>clicks. This change:GETtoPOSTreq.session.destroy()to fully invalidate the server-side session afterreq.logout()res.clearCookie('connect.sid')to remove the session cookie from the browserChanges
backend/routes/auth.js: Route method changed fromGETtoPOST; added session destruction and cookie clearingTest plan
POST /api/auth/logoutreturns 200 and{ message: 'Logged out successfully' }connect.sidcookie is absent from the responseGET /api/auth/logoutnow returns 404Could you please add the appropriate GSSoC labels (
gssoc26,type:security,level:intermediate) when you get a chance? Thank you!