MM-68375: Verify channel membership before posting from createissue nd createissuecomment handlers#1009
MM-68375: Verify channel membership before posting from createissue nd createissuecomment handlers#1009nang2049 wants to merge 1 commit into
Conversation
…nd createissuecomment handlers
📝 WalkthroughWalkthroughPermission checks added to GitHub write actions: ChangesGitHub Write Action Permission Enforcement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/plugin/api.go (1)
1030-1033: ⚡ Quick winAdd regression tests for all three authorization branches.
This closes a security-sensitive gap in three separate paths, but there’s no accompanying handler coverage here for the forbidden case. Please add API tests for
/createissuecommentwith an inaccessiblepost_id, plus/createissuefor both thechannel_idandpost_idmodes, so this private-channel posting bug doesn’t regress silently.Also applies to: 1734-1737, 1754-1757
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/plugin/api.go` around lines 1030 - 1033, Add regression API tests covering the three authorization branches that return forbidden when the user lacks channel post permissions: write a test for the /createissuecomment handler that calls with an inaccessible post_id and asserts the response is HTTP 403 and the API error message matches the path in api.go where p.client.User.HasPermissionToChannel(...) triggers the forbidden branch; also add two tests for /createissue covering both modes (channel_id mode and post_id mode) that simulate a user without permission on the target channel/post and assert HTTP 403 and the same error response. Ensure the tests exercise the exact handlers that call p.client.User.HasPermissionToChannel and the code paths referenced around lines 1030 and the similar checks at 1734-1737 and 1754-1757.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@server/plugin/api.go`:
- Around line 1030-1033: Add regression API tests covering the three
authorization branches that return forbidden when the user lacks channel post
permissions: write a test for the /createissuecomment handler that calls with an
inaccessible post_id and asserts the response is HTTP 403 and the API error
message matches the path in api.go where
p.client.User.HasPermissionToChannel(...) triggers the forbidden branch; also
add two tests for /createissue covering both modes (channel_id mode and post_id
mode) that simulate a user without permission on the target channel/post and
assert HTTP 403 and the same error response. Ensure the tests exercise the exact
handlers that call p.client.User.HasPermissionToChannel and the code paths
referenced around lines 1030 and the similar checks at 1734-1737 and 1754-1757.
Summary
fix reported via Bugcrowd. Both
/api/v1/createissueand/api/v1/createissuecommentaccepted apost_idloaded the referenced post and created a reply in that post's channel without checking that the calling user could post there. An authenticated user could supply apost_idfrom a private channel they were not a member of and have the plugin reply on their behalf in that channel.Ticket Link
https://mattermost.atlassian.net/browse/MM-68375
QA with Curl
Create two users:
User A is member of a private channel
User B is not a member
Connect User B via /github connect. User B needs at least one repo they can create issues on.
As User A post any message in private-test. Right-click → Copy ID.
Get User B's session token: in their browser DevTools → Application → Cookies → MMAUTHTOKEN.
Verified:
Same for createissue with post_id.