fix: profile update no longer trusts a client-supplied userId (IDOR) - #269
fix: profile update no longer trusts a client-supplied userId (IDOR)#269RudraDudhat2509 wants to merge 1 commit into
Conversation
updateStudentProfile looked up the target user by a userId taken straight from req.body, with no check that it matched the logged-in session. Any authenticated user — including a plain student — could edit any other user's profile (name, email, phone, academic info incl. CGPA, hostel, social links) just by supplying their student ID. Now always resolves the target user from req.user (the authenticated session) instead. Fixes OpenLake#258
|
@RudraDudhat2509 is attempting to deploy a commit to the openlake's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 38 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
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 |
Fixes #258
What changed
updateStudentProfileresolved the account to edit via auserIdfield taken straight fromreq.body, with no check that it belonged to the logged-in session (onlyisAuthenticated, no ownership check). Any authenticated user — including a plain student — could edit any other user's profile (name, email, phone, academic info including CGPA, hostel, social links) just by supplying that user's student ID.Fix: always resolve the target account from
req.user(the authenticated session), never from client input.Testing
Added
profileController.updateStudentProfile.test.js(jest + supertest + in-memory Mongo). Simulates a logged-in "attacker" account attempting to overwrite a "victim" account's name and CGPA by passing the victim'suserId, then checks the victim's record in the database directly.Verified the test is meaningful — ran it against the old code first, and it reproduces the exploit exactly:
Run with
npm testinbackend/.