[HIGH] Prevent mass assignment and add role-based auth to admin endpoints (Fixes #2894)#2897
Conversation
|
@namann5 is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Mass Assignment Vulnerability — Any Authenticated User Can Modify Any Profile Field (Privilege Escalation)
Severity: HIGH (CVSS 8.0)
Location:
backend/routers/admin.py:17Description
The
PATCH /profiles/{user_id}endpoint accepts a rawupdates: dictparameter without a Pydantic schema or field allowlist. Any authenticated user can update ANY field on ANY user's profile, including:role— escalate to admin/master_adminstatus— bypass email verification, suspend other userscompany_id— change tenant assignmentemail— take over other accountsThere is NO:
Impact
role: "admin"orrole: "master_admin"on their own profilecompany_idto access other organizations' dataProof of Concept
Fix
Use a Pydantic model to restrict updatable fields:
And add role-based authorization:
References
backend/routers/admin.py:17—updates: dictwithout schema