Skip to content

fix: profile update no longer trusts a client-supplied userId (IDOR) - #269

Open
RudraDudhat2509 wants to merge 1 commit into
OpenLake:mainfrom
RudraDudhat2509:fix/profile-update-idor
Open

fix: profile update no longer trusts a client-supplied userId (IDOR)#269
RudraDudhat2509 wants to merge 1 commit into
OpenLake:mainfrom
RudraDudhat2509:fix/profile-update-idor

Conversation

@RudraDudhat2509

Copy link
Copy Markdown
Collaborator

Fixes #258

What changed

updateStudentProfile resolved the account to edit via a userId field taken straight from req.body, with no check that it belonged to the logged-in session (only isAuthenticated, 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's userId, 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:

BEFORE (old code): expected victim's name to stay "Victim", got "Hacked Name" — test fails
AFTER  (this fix):  victim's record untouched — test passes

Run with npm test in backend/.

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
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@RudraDudhat2509, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f131e05a-2afa-44fe-b6fa-cd5f500da7d3

📥 Commits

Reviewing files that changed from the base of the PR and between 3a38811 and f562641.

⛔ Files ignored due to path filters (1)
  • backend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • backend/controllers/profileController.js
  • backend/package.json
  • backend/tests/profileController.updateStudentProfile.test.js

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: Broken object-level authorization on profile update (any user can edit any other user's profile)

1 participant