[WEB-8400] fix(security): scope DeployBoardViewSet queryset to the URL workspace/project (GHSA-h4w5-vhxc-265g) - #9481
Conversation
…L workspace/project (GHSA-h4w5-vhxc-265g) DeployBoardViewSet defines only list/create; the routed retrieve/partial_update/ destroy fall through to DRF's ModelViewSet defaults, which resolve the object via get_object() -> get_queryset(). The base get_queryset returns DeployBoard.objects.all() (every workspace), and ProjectMemberPermission only checks the URL slug/project_id — nothing binds the object to that scope. So any authenticated user could supply their own workspace+project in the URL and a victim board's pk (disclosed unauth via the public settings endpoint) to read, modify, or hard-delete any workspace's published board. Override get_queryset to scope to the URL workspace__slug + project so a foreign pk 404s. Adds 4 contract tests (cross-workspace retrieve/destroy/patch blocked, own board retrievable); fail-before verified. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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)
📝 WalkthroughWalkthrough
ChangesDeploy board access scoping
Estimated code review effort: 2 (Simple) | ~15 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 |
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/tests/contract/app/test_deploy_board_cross_workspace_scope_app.py`:
- Around line 53-64: Extend the contract tests around the existing victim_board
and project-scoped board URL to create a second project within the caller’s
workspace, add a board for that project, and assert the project_a URL returns
404 for it. Keep the test setup using the same workspace while ensuring the
endpoint remains constrained by both workspace slug and URL project identifier.
🪄 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: c9fcb447-d205-4b1f-8abc-ef6e31fcc787
📒 Files selected for processing (2)
apps/api/plane/app/views/project/base.pyapps/api/plane/tests/contract/app/test_deploy_board_cross_workspace_scope_app.py
…Rabbit #9481) The negative cases all used a different workspace, so they'd pass even if the project predicate were dropped from get_queryset (workspace slug alone would catch them). Add a board for a different project in the SAME workspace and assert it 404s via project_a's URL, guarding the project_id/entity_identifier scope. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
DeployBoardViewSet(apps/api/plane/app/views/project/base.py) defines onlylist/create. The routedretrieve/partial_update/destroy(.../project-deploy-boards/<pk>/) are not defined on the class and fall through to DRF'sModelViewSetdefaults, which resolve the object viaget_object()→get_queryset(). The baseget_querysetreturnsDeployBoard.objects.all()(every workspace), andProjectMemberPermissiononly reads the URL slug/project_id — nothing binds the object to that scope, and nohas_object_permissionexists.So any authenticated user could put their own workspace+project in the path and a victim board's pk as the target to read, modify, or hard-delete any workspace's published board. The victim pk is disclosed unauthenticated by the public board-settings endpoint (
fields="__all__"). Same defect class as GHSA-rfj3-8c85-g46j / GHSA-4q54-h4x9-m329.Fixes GHSA-h4w5-vhxc-265g (CWE-639/862). Confirmed vulnerable against
origin/preview@a8e53b6ac7.Fix
Override
get_querysetonDeployBoardViewSetto scope to the URLworkspace__slug+project(entity_name="project",entity_identifier/project_id= URL project).get_object()then 404s for any board outside the caller's URL scope.list/createare unaffected (they build their own queries).Tests
test_deploy_board_cross_workspace_scope_app.py— cross-workspace retrieve (404), destroy (404 + board still exists), patch (404 + unchanged); own board retrievable (200). Fail-before verified; ruff clean.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests