Repository navigation
[INFRA-1138] fix(security): require workspace admin to PUT/PATCH workspace - #10042
Conversation
…workspace WorkSpaceBasePermission allowed the Member role for PUT/PATCH, so PUT reached the undecorated update() action. It now requires Admin, matching partial_update; the unused duplicate in plane.utils.permissions gets the same change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
Make deleted_at read-only in WorkSpaceSerializer so an update cannot set it, and reword the test module docstring as a neutral statement of the rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lovelace3
left a comment
There was a problem hiding this comment.
No blocking findings in the diff.
Verified:
test_workspace_update_admin_scope_app.py,test_workspace_app.pyandtest_workspace_member_mass_assignment_app.py: 22 passed at the head.- Falsification: with both permission modules and the serializer reverted to the merge-base,
test_non_admin_cannot_update_workspace[15-put]andtest_update_leaves_deleted_at_unchangedfail. The other non-admin cases already got a 403 before the PR: Guest was never allowed, and PATCH had@allow_permission([ROLE.ADMIN]). WorkSpaceViewSetis the only consumer ofWorkSpaceBasePermission.create()doesn't setdeleted_at, so making it read-only doesn't affect creation.
Out of scope, pre-existing (Minor), for a follow-up ticket: "workspace settings are admin-only" still has one gap. WorkspaceFileAssetEndpoint.delete (app/views/asset/v2.py, @allow_permission([ADMIN, MEMBER, GUEST])) passes WORKSPACE_LOGO assets to entity_asset_delete, which clears workspace.logo_asset_id. A throwaway probe confirmed it: a Guest or Member DELETE returned 204 and the workspace logo was unset. Upload is already admin-gated (WORKSPACE_LOGO may only be uploaded by workspace admins), so the gap is only on delete (and on the PATCH that re-points the asset). The impact is cosmetic, but it is the same class of issue.
|
Re the workspace logo delete note: this is handled in #10068, which applies per-entity-type modify rules to the workspace asset endpoints, so workspace-logo assets can only be updated or deleted by a workspace admin. Leaving it out of this PR to keep the scope tight. |
…space (#10042) * [INFRA-1138] fix(security): require workspace admin to PUT/PATCH the workspace WorkSpaceBasePermission allowed the Member role for PUT/PATCH, so PUT reached the undecorated update() action. It now requires Admin, matching partial_update; the unused duplicate in plane.utils.permissions gets the same change. * [INFRA-1138] fix: address review Make deleted_at read-only in WorkSpaceSerializer so an update cannot set it, and reword the test module docstring as a neutral statement of the rule.
Description
WorkSpaceBasePermissionallowed the workspace Member role forPUT/PATCHon/api/workspaces/<slug>/.partial_updateadds its own admin check, butPUTroutes to the inheritedupdate, which has none.WorkSpaceBasePermissionnow requires the Admin role forPUTandPATCH, the same asDELETE. This matches the existing comment and the@allow_permission([ROLE.ADMIN])onpartial_update.plane.utils.permissions.workspacegets the same change, so the two stay in sync.deleted_atis now read-only inWorkSpaceSerializer, so an update cannot soft-delete the workspace; deletion goes throughdestroy()only.WorkSpaceViewSetis the only viewset that uses this class. The web app only sendsPATCHhere, which was already admin-only, so no existing UI flow changes.Behaviour change: a non-admin
PUT /api/workspaces/<slug>/now returns 403, anddeleted_atin an update payload is ignored.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
PUTorPATCHto/api/workspaces/<slug>/→ 403, and the workspace is unchanged.PUTorPATCH→ 200, and the change is saved.PATCHwithdeleted_at→ 200, anddeleted_atstays empty.plane/tests/contract/app/test_workspace_update_admin_scope_app.py(new),test_workspace_app.pyandtest_workspace_member_mass_assignment_app.py: 21 passed. The MemberPUTcase fails without the fix.test_workspace_app.py(3) pass; thedeleted_atcase fails without the serializer change.References
🤖 Generated with Claude Code
Summary by CodeRabbit