Skip to content

[INFRA-1132] fix(security): cap invitation role updates at own role - #10041

Merged
sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1132-invite-update-role-cap
Oct 17, 2026
Merged

sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1132-invite-update-role-cap

Conversation

@dheeru0198

@dheeru0198 dheeru0198 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Description

PATCH /api/workspaces/<slug>/invitations/<pk>/ was served by DRF's generic partial_update, so it saved any writable field and skipped the role cap that create() applies.

  • WorkspaceInvitationsViewset.partial_update is now implemented explicitly.
  • It accepts only a {"role": ...} payload; any other key (for example accepted) returns 400 and writes nothing.
  • The new role cannot be higher than the requester's own workspace role, the same rule as create() and the role dropdown in the invitations list.

Behaviour change: a Member setting a pending invitation to Admin now gets a 400. Admins, and Members choosing Member or Guest, are unaffected. The web client only sends {role}, so nothing changes there.

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

  • As a workspace Member, change a pending invitation from Member to Admin → 400, role unchanged.
  • As a workspace Member, change a pending invitation to Guest → 200.
  • As a workspace Admin, change a pending invitation to Admin → 200.
  • PATCH with accepted (alone or with role) → 400, invitation unchanged.
  • test_workspace_invitation_update_app.py, test_workspace_app.py, test_workspace_member_mass_assignment_app.py: 21 passed. Without the fix, 3 of the 6 new tests fail.

References

  • INFRA-1132
  • INFRA-1155

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Workspace invitations can now be updated by changing their role. Members can assign roles no higher than their own, while admins can assign admin-level roles.
    • Invitation updates accept only a role change. Requests with additional fields or an invalid request body are rejected, and rejected requests leave the invitation unchanged.

…ter's role

WorkspaceInvitationsViewset.partial_update was served by the generic mixin, which
skipped the role cap create() enforces. It now accepts only {"role"} and rejects a
role above the requester's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:54

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.

@makeplane

makeplane Bot commented Oct 16, 2026

Copy link
Copy Markdown

@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: 00942c2c-54a1-4f3c-9e53-d8891a857774
📥 Commits

Reviewing files that changed from the base of the PR and between 4be8487 and 3e20c4d.

📒 Files selected for processing: 1
  • apps/api/plane/tests/contract/app/test_workspace_invitation_update_app.py
🚧 Files skipped from review as they are similar to previous changes: 1
  • apps/api/plane/tests/contract/app/test_workspace_invitation_update_app.py

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

📝 Walkthrough

The workspace invitation API now supports partial updates that change an invitation’s role. Contract tests cover role limits, accepted updates, and rejected request bodies.

Changes: Workspace invitation updates

Layer / File(s) Summary
Validate and update invitation roles
apps/api/plane/app/views/workspace/invite.py, apps/api/plane/tests/contract/app/test_workspace_invitation_update_app.py
The endpoint accepts payloads containing only role and rejects roles above the active requester’s role. Contract tests cover member and admin updates, extra fields, and list bodies.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3e20c

The invitation-update tests cover the identified role and invalid-payload behavior. No issue identified here prevents merging after normal checks.

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 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main security change: limiting invitation role updates to the requester's own role.
Description check Passed The description includes the required sections, explains the security fix, identifies the behavior change, lists test scenarios and results, and provides references. Screenshots are not applicable to …
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.
Full details: Description check

Explanation

The description includes the required sections, explains the security fix, identifies the behavior change, lists test scenarios and results, and provides references. Screenshots are not applicable to this API change.

  • 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.

Reword the invitation update test docstring and one test name as a neutral
statement of the role cap 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.

Verified:

  • test_workspace_invitation_update_app.py, test_workspace_app.py and test_workspace_member_mass_assignment_app.py: 21 passed at the head.
  • Falsification: with invite.py reverted to the merge-base, 3 of the 6 new cases fail (the Member→Admin cap and both accepted bodies). The other three are positive or 400-either-way cases, as the PR description says.
  • Sibling surfaces: the v1 plane/api/views/invite.py partial_update is behind WorkspaceOwnerPermission (Admin only), and its serializer validates role and makes accepted read-only. The project invitation routes expose no PATCH. The URL map has no put for this viewset, so the inherited update can't be reached.
  • role goes through the model ChoiceField, so out-of-range values are rejected before the cap check. The web client (invitations-list-item.tsx) sends only {role}, so its requests are unaffected.

@sriramveeraghanta
sriramveeraghanta merged commit c29a5c1 into preview Oct 17, 2026
16 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1132-invite-update-role-cap branch October 17, 2026 10:35
sriramveeraghanta pushed a commit that referenced this pull request Oct 22, 2026
…10041)

* [INFRA-1132] fix(security): cap invitation role updates at the requester's role

WorkspaceInvitationsViewset.partial_update was served by the generic mixin, which
skipped the role cap create() enforces. It now accepts only {"role"} and rejects a
role above the requester's own.

* [INFRA-1132] test: address review

Reword the invitation update test docstring and one test name as a neutral
statement of the role cap rule.
questbibek pushed a commit to questbibek/plane that referenced this pull request Nov 23, 2026
…akeplane#10041)

* [INFRA-1132] fix(security): cap invitation role updates at the requester's role

WorkspaceInvitationsViewset.partial_update was served by the generic mixin, which
skipped the role cap create() enforces. It now accepts only {"role"} and rejects a
role above the requester's own.

* [INFRA-1132] test: address review

Reword the invitation update test docstring and one test name as a neutral
statement of the role cap rule.

(cherry picked from commit 03cff62)
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