fix: enforce ownership on campaign update (IDOR)#26
Open
Adeolu01 wants to merge 1 commit into
Open
Conversation
Contributor
|
@Adeolu01 please fix the CI thanks. |
Contributor
|
Clean, focused IDOR fix — the ownership check + audit log is exactly the right shape. Thanks for picking this up 🙌 |
Contributor
|
Heads up: this now has a merge conflict on |
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.
Closes #19
CampaignsService.updateCampaignaccepted auserIdbut never used it, so any authenticated wallet holder could overwrite thetitle,description,story, andimageUrlof every campaign — a textbook OWASP A01:2021 Broken Access Control / IDOR, withimageUrl/storyusable for phishing injection and no audit trail.Changes:
updateCampaign: reject with403 Forbiddenunless the caller is the campaign creator or an admin, mirroring the existingdeleteUpdateadmin-flag pattern.req.user.id, which is undefined) — now usesreq.user.suband derivesisAdminfromreq.user.role.AuditLogrow (CAMPAIGN_UPDATED) on every successful update recording actor, target campaign, and the applied diff.403when wallet A edits a campaign owned by wallet B (including thecoverImageUrl/phishing case), plus owner-success and admin-override coverage.Note:
@Roles('CREATOR','ADMIN')was intentionally not added to the route — campaign creation does not promote aUSERtoCREATOR, so that decorator would lock legitimate owners out of their own campaigns. Per-resource ownership is the correct boundary.