Repository navigation
fix: strengthen CSRF token validation middleware - #2408
Nithya-3035 wants to merge 1 commit into
Conversation
Improved CSRF protection in `backend/middlewares/csrfHeaderCheck.js`. - Added input type validation for cookie and header tokens. - Improved handling of missing or invalid CSRF tokens. - Used Node.js `crypto.timingSafeEqual()` for secure token comparison. - Added buffer length checks before comparing tokens. - Added error handling to prevent unexpected middleware failures. - Standardized HTTP 403 error responses. - Preserved the existing CommonJS middleware export. These changes improve CSRF token validation, security, and backend reliability.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
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. |
|
Thank you for submitting your pull request, @Nithya-3035! 🙌 |
|
Thank you for your contribution! To keep reviews manageable and maintain repository quality, contributors may have a maximum of 3 open Issues and 3 open Pull Requests at any given time. Please wait until one of your existing submissions is reviewed or closed before opening additional ones. If you believe this was closed by mistake, feel free to contact the maintainers. |
Improved CSRF protection in
backend/middlewares/csrfHeaderCheck.js.crypto.timingSafeEqual()for secure token comparison.These changes improve CSRF token validation, security, and backend reliability.
📝 Pull Request Description
Related Issue
Closes #
Summary
Provide a short, reviewer-friendly summary of what changed and why.
Type of Change
How Has This Been Tested?
Describe the testing steps performed.
Screenshots (if applicable)
Add screenshots or videos to demonstrate the changes.
Checklist