fix: validate upload ownership in sendFileMessage#38894
fix: validate upload ownership in sendFileMessage#38894sahillllllllll-bit wants to merge 1 commit into
sendFileMessage#38894Conversation
|
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2026-02-12T15:39:28.416ZApplied to files:
📚 Learning: 2025-11-04T16:49:19.107ZApplied to files:
🔇 Additional comments (1)
WalkthroughAdds upload ownership and room association validation to the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
@KevLehman please review this if you have time :) and sorry for the mention |
|
Closing in favor of #39010, thx for the work! |
Proposed changes (including videos or screenshots)
This PR fixes an authorization flaw in the file message flow.
The method
sendFileMessagetrusted the client-suppliedfile._idand immediately finalized the upload usingUploads.updateFileComplete.The server did not validate whether the upload document actually belonged to the requesting user or was associated with the target room.
Because
_idis attacker-controlled input, an authenticated user could provide the_idof an existing upload and attach another user’s file to a room they had access to.Fix
The server now validates ownership and room association before completing the upload:
_idupload.userId === currentUser._idupload.rid === roomIdIf validation fails, the method throws
error-invalid-file.This prevents unauthorized file finalization and protects upload ownership integrity.
Issue(s)
Closes: #38892
Steps to test or reproduce
_idfrom the network request (/ufs/upload response)sendFileMessage(or intercept the client request) and provide User A’s upload_idBefore fix
The file is successfully attached to the room even though it belongs to User A.
After fix
The server rejects the request and returns
error-invalid-file.Further comments
This is an example of an Insecure Direct Object Reference (IDOR) vulnerability.
The server relied on a client-provided identifier without verifying resource ownership.
The added validation ensures that uploads can only be finalized by their original uploader and only in the room they were uploaded for.
The change only introduces authorization checks and does not modify the normal upload workflow for valid users.
Summary by CodeRabbit