fix(security): prevent team webhook IDOR by enforcing ADMIN/OWNER role check (#29982) - #30009
fix(security): prevent team webhook IDOR by enforcing ADMIN/OWNER role check (#29982)#30009jihadMo wants to merge 1 commit into
Conversation
|
Welcome to Cal.diy, @jihadMo! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughWebhook lookup results now include Merge Risk: ⚪ Minimal · up to The change adds ADMIN/OWNER authorization for team webhook access while preserving existing ownership checks; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 Warning |
Closes #29982
Summary of Changes
teamIdselection and explicit authorization verification increateWebhookProcedure()middleware (packages/trpc/server/routers/viewer/webhook/util.ts).webhook.teamId), the middleware checksprisma.membership.findFirst({ where: { teamId: webhook.teamId, userId: ctx.user.id, accepted: true, role: { in: ["ADMIN", "OWNER"] } } })and throwsTRPCErrorwithFORBIDDENif the caller lacks administrative rights on the owning team.Verification
webhook.userId === ctx.user.id.eventType.userId === ctx.user.id.ADMINorOWNERmembership.