Skip to content

[INFRA-1138] fix(security): require workspace admin to PUT/PATCH workspace - #10042

Merged
sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1138-workspace-put-admin-only
Oct 17, 2026
Merged

sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1138-workspace-put-admin-only

Conversation

@dheeru0198

@dheeru0198 dheeru0198 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Description

WorkSpaceBasePermission allowed the workspace Member role for PUT/PATCH on /api/workspaces/<slug>/. partial_update adds its own admin check, but PUT routes to the inherited update, which has none.

  • WorkSpaceBasePermission now requires the Admin role for PUT and PATCH, the same as DELETE. This matches the existing comment and the @allow_permission([ROLE.ADMIN]) on partial_update.
  • The duplicate class in plane.utils.permissions.workspace gets the same change, so the two stay in sync.
  • deleted_at is now read-only in WorkSpaceSerializer, so an update cannot soft-delete the workspace; deletion goes through destroy() only.
  • WorkSpaceViewSet is the only viewset that uses this class. The web app only sends PATCH here, which was already admin-only, so no existing UI flow changes.

Behaviour change: a non-admin PUT /api/workspaces/<slug>/ now returns 403, and deleted_at in an update payload is ignored.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • Workspace Member or Guest sends PUT or PATCH to /api/workspaces/<slug>/ → 403, and the workspace is unchanged.
  • Workspace Admin sends PUT or PATCH → 200, and the change is saved.
  • Admin sends PATCH with deleted_at → 200, and deleted_at stays empty.
  • Admin renames the workspace in Settings → General → works as before.
  • plane/tests/contract/app/test_workspace_update_admin_scope_app.py (new), test_workspace_app.py and test_workspace_member_mass_assignment_app.py: 21 passed. The Member PUT case fails without the fix.
  • After the review change: the new file (7) and test_workspace_app.py (3) pass; the deleted_at case fails without the serializer change.

References

  • INFRA-1138

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Access Control
    • Restricted workspace updates to active admins. Members and guests receive a 403 response; admins can still update workspace details.
  • Workspace Settings
    • Workspace updates can no longer change the deletion status.
  • Tests
    • Added coverage for workspace updates using PUT and PATCH across admin, member, and guest roles.

…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>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 656fd81a-99fc-4a29-ad12-50ff89c3adc0
📥 Commits

Reviewing files that changed from the base of the PR and between e8a0e25 and 87238c9.

📒 Files selected for processing: 2
  • apps/api/plane/app/serializers/workspace.py
  • apps/api/plane/tests/contract/app/test_workspace_update_admin_scope_app.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Workspace PUT and PATCH requests now require the active Admin role. The workspace serializer also prevents updates to deleted_at. Contract tests cover role access, workspace-name changes, and the deleted_at field.

Changes: Workspace Update Permissions

Layer / File(s) Summary
Admin-only workspace updates
apps/api/plane/app/permissions/workspace.py, apps/api/plane/utils/permissions/workspace.py, apps/api/plane/tests/contract/app/test_workspace_update_admin_scope_app.py
Both permission filters now require the Admin role for workspace PUT and PATCH requests. Contract tests check guest, member, and admin access and whether the workspace name changes.
Read-only deleted_at
apps/api/plane/app/serializers/workspace.py, apps/api/plane/tests/contract/app/test_workspace_update_admin_scope_app.py
The serializer marks deleted_at as read-only. A contract test checks that an admin PATCH leaves the stored field as None.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 87238

Workspace updates are restricted to active admins, and PATCH cannot change deleted_at. The reviewed changes leave no material merge risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the security change: workspace PUT/PATCH requests now require an admin.
Description check Passed The description includes all required sections, explains the permission and serializer changes, documents behavior changes, lists test scenarios and results, and references INFRA-1138.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@makeplane

makeplane Bot commented Oct 16, 2026

Copy link
Copy Markdown

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 lovelace3 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings in the diff.

Verified:

  • test_workspace_update_admin_scope_app.py, test_workspace_app.py and test_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] and test_update_leaves_deleted_at_unchanged fail. The other non-admin cases already got a 403 before the PR: Guest was never allowed, and PATCH had @allow_permission([ROLE.ADMIN]).
  • WorkSpaceViewSet is the only consumer of WorkSpaceBasePermission. create() doesn't set deleted_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.

@dheeru0198

Copy link
Copy Markdown
Member Author

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.

@sriramveeraghanta
sriramveeraghanta merged commit ca521bd into preview Oct 17, 2026
16 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1138-workspace-put-admin-only branch October 17, 2026 10:36
sriramveeraghanta pushed a commit that referenced this pull request Oct 22, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants