Fix IDOR in Kits, BroadcastAnnouncements, and Distributions controllers#5514
Open
costajohnt wants to merge 2 commits intorubyforgood:mainfrom
Open
Fix IDOR in Kits, BroadcastAnnouncements, and Distributions controllers#5514costajohnt wants to merge 2 commits intorubyforgood:mainfrom
costajohnt wants to merge 2 commits intorubyforgood:mainfrom
Conversation
…utions controllers Scope all find-by-id queries through current_organization to prevent cross-organization data access (CWE-639). KitsController: deactivate, reactivate, allocations, allocate BroadcastAnnouncementsController: set_broadcast_announcement (edit/update/destroy) DistributionsController: print, show, edit, update, destroy Closes rubyforgood#5509 (partial - 3 of 5 controllers)
9203d1b to
91fecf4
Compare
Verify the distribution record is unchanged after a rejected cross-org update attempt, matching the pattern used in the broadcast announcements spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes cross-organization IDOR vulnerabilities (CWE-639) in three controllers by scoping all
find(params[:id])calls throughcurrent_organization:deactivate,reactivate,allocations,allocate(4 endpoints)set_broadcast_announcementbefore_action used byedit,update,destroy(3 endpoints)print,show,edit,update,destroy(5 endpoints)Previously, these endpoints used unscoped
Model.find(params[:id]), allowing an authenticated user from one organization to access, modify, or delete records belonging to a different organization by guessing or enumerating IDs.Changes
Kit.find(params[:id])withcurrent_organization.kits.find(params[:id])in 4 actionsBroadcastAnnouncement.find(params[:id])withBroadcastAnnouncement.where(organization_id: current_organization.id).find(params[:id])(nohas_manyassociation available)Distribution.find(params[:id])/Distribution.includes(...).find(params[:id])withcurrent_organization.distributions.find(params[:id])in 5 actionsdestroybefore delegating toDistributionDestroyServiceTest Plan
Partial fix for #5509 (3 of 5 controllers).