[WEB-8382][WEB-8383] fix(security): external-API issue comment + attachment authz (GHSA-h4p4, GHSA-xvc5) - #9475
[WEB-8382][WEB-8383] fix(security): external-API issue comment + attachment authz (GHSA-h4p4, GHSA-xvc5)#9475mguptahub wants to merge 2 commits into
Conversation
…chment authz (GHSA-h4p4-mwfg-qh82, GHSA-xvc5-m5jf-gvpj) Two authorization gaps in the external API (api/views/issue.py): - GHSA-h4p4: IssueCommentDetailAPIEndpoint uses ProjectLitePermission (any active project member) and edited/deleted comments by id with no author/admin check — a Guest could tamper with or delete anyone's comments. patch/delete now require the comment author OR a project admin (403 otherwise), matching the app. - GHSA-xvc5: IssueAttachmentListCreateAPIEndpoint.get had no permission_classes (bare IsAuthenticated) and no membership check, while post calls user_has_issue_permission. Since API tokens authenticate globally, any token holder could list any issue's attachment metadata cross-tenant. get now enforces project membership on the issue, mirroring post. Adds 6 contract tests (guest comment patch/delete 403, author/admin allowed; outsider attachment list 403, member allowed); fail-before verified. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Linked to Plane Work Item(s)
This comment was auto-generated by Plane |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe issue API now restricts comment updates and deletions to authors or active project admins. It also checks project roles or issue ownership before listing attachment metadata. Contract tests cover allowed and denied API-token requests. ChangesIssue API authorization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/api/plane/tests/contract/api/test_external_api_issue_authz.py (1)
125-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winComplete the allowed comment-operation matrix.
These tests cover author PATCH and admin DELETE, but not author DELETE or admin PATCH. Add both cases so either endpoint cannot regress for one permitted actor unnoticed.
🤖 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 `@apps/api/plane/tests/contract/api/test_external_api_issue_authz.py` around lines 125 - 142, Add tests alongside test_author_can_patch_own_comment and test_admin_can_delete_comment covering author DELETE and admin PATCH. Use _token_client(author) and _token_client(create_user) respectively, assert HTTP 204 for author deletion and HTTP 200 for admin editing, and follow the existing COMMENT_URL construction and response-detail assertions.
🤖 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.
Inline comments:
In `@apps/api/plane/api/views/issue.py`:
- Around line 1612-1615: Add the missing HTTP 403 response documentation to the
explicit OpenAPI response maps for update_work_item_comment,
delete_work_item_comment, and list_work_item_attachments in
apps/api/plane/api/views/issue.py at lines 1612-1615, 1690-1693, and 2038-2041,
respectively, matching the existing response schema and style.
---
Nitpick comments:
In `@apps/api/plane/tests/contract/api/test_external_api_issue_authz.py`:
- Around line 125-142: Add tests alongside test_author_can_patch_own_comment and
test_admin_can_delete_comment covering author DELETE and admin PATCH. Use
_token_client(author) and _token_client(create_user) respectively, assert HTTP
204 for author deletion and HTTP 200 for admin editing, and follow the existing
COMMENT_URL construction and response-detail assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5618f88c-6bde-4cca-8c52-5cf195a86b42
📒 Files selected for processing (2)
apps/api/plane/api/views/issue.pyapps/api/plane/tests/contract/api/test_external_api_issue_authz.py
…ract The author/admin guard on comment update+delete and the project-membership guard on attachment list all return 403, but their explicit `responses` maps omitted it, so the generated schema advertised only 400/404/409. Adds `403: FORBIDDEN_RESPONSE` (already imported) to update_work_item_comment, delete_work_item_comment and list_work_item_attachments. Addresses CodeRabbit review on #9475. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
React Doctor found no issues. 🎉
|
Summary
Two authorization gaps in the external API (
apps/api/plane/api/views/issue.py), both confirmed vulnerable againstorigin/preview@a8e53b6ac7:GHSA-h4p4-mwfg-qh82 — comment tampering (WEB-8382)
IssueCommentDetailAPIEndpointis guarded byProjectLitePermission(any active project member, incl. Guest) and edited/deleted comments by id with no author/admin check. A Guest could modify or delete any other user's comments — including an admin's. The web app restricts this to the comment's creator or a project admin; the external API dropped both checks.GHSA-xvc5-m5jf-gvpj — cross-tenant attachment metadata disclosure (WEB-8383)
IssueAttachmentListCreateAPIEndpoint.getsets nopermission_classes(inherits bareIsAuthenticated) and does no membership check, while itspostcallsuser_has_issue_permission. Because API tokens authenticate globally (not workspace-scoped), any token holder could list any issue's attachment metadata (filenames, sizes, S3 keys, uploader) across tenants.Fix
patch/delete: requirecreated_by == request.useror project admin (ProjectMember role=ADMIN), else 403.get: load the issue scoped to the URL workspace/project and enforceuser_has_issue_permission([ADMIN, MEMBER, GUEST], allow_creator=True), mirroringpost.Tests
tests/contract/api/test_external_api_issue_authz.py— 6 tests: guest cannot patch/delete a comment (403, unchanged), author can patch own + admin can delete (positive); outsider (token, no membership) cannot list attachments (403), project member can (positive). Fail-before verified; ruff clean.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests