Skip to content

[SECUR-248] fix(security): guard ProjectViewSet PUT — routed verb falls through to DRF - #9603

Closed
mguptahub wants to merge 2 commits into
previewfrom
secur-248/project-viewset-put-guard
Closed

[SECUR-248] fix(security): guard ProjectViewSet PUT — routed verb falls through to DRF#9603
mguptahub wants to merge 2 commits into
previewfrom
secur-248/project-viewset-put-guard

Conversation

@mguptahub

@mguptahub mguptahub commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

app/urls/project.py:40 maps "put": "update", but ProjectViewSet never defined update — so PUT fell through to DRF's ModelViewSet.update. The class sets no permission_classes, so that generic handler ran under the project default of IsAuthenticated, while partial_update on the identical URL does an inline workspace-admin / project-admin check.

PATCH was authorised. PUT was not.

Verified against preview @ 1c8a60f858. Closes 2 HIGH advisories (SECUR-248 carries the mapping).

Impact — reproduced

A workspace MEMBER with no ProjectMember row for a network=0 (Secret) project:

  1. PUT .../projects/<id>/ with network: 2200 OK, project becomes Public
  2. Join via the legitimate public-project API → ProjectMember(role=15)
  3. Full read plus member-level write on a project they were never in

Step 1 confirmed in the fail-before run: an unpatched non-member PUT returns 200 and flips network.

The change

def update(self, request, slug, pk=None):
    return self.partial_update(request, slug=slug, pk=pk)

Both verbs now enforce the same rule. A full PUT-replace is not a meaningful operation for projects — the client only ever sends PATCH.

This follows the pattern #9461 established for the work-item / module / intake instances of the same defect. It does not need that PR's partial_update.__wrapped__ trick: ProjectViewSet.partial_update carries no decorator (it authorises inline), so calling it directly does not double-authorise.

Tests

Four contract tests:

  • non-member PUT is denied
  • a denied PUT writes nothing — a 403 that still flipped network would leave the project published, which is the actual damage
  • PUT and PATCH reach the same verdict — the defect was precisely that they disagreed
  • positive control — a workspace admin PUT still succeeds

Fail-before verified: 3 failed / 1 passed unpatched → 4 passed patched. The positive control passes in both runs, confirming it is independent of the change.

⚠️ The payload must be complete. DRF's generic update runs the serializer with partial=False, so an incomplete body 400s on validation before authorization differs at all — with a partial body the tests passed with and without the fix and proved nothing. full_put_body() exists for that reason and the docstring says so.

Related — a broader finding

The ticket asked for a sweep for other instances. Checking every as_view({...}) mapping in app/urls/ against whether the viewset defines that action, then filtering to classes with no class-level permission_classes:

routed DRF-generic actions the viewset does not define 68
of those, on classes with no class-level permission_classes 34
already covered by open PR #9461 4
ProjectViewSet PUT (this PR) 1
unaddressed 29

Examples, all on classes whose defined actions carry @allow_permission/@can while the undefined one gets nothing: CycleViewSet PUT, IssueViewViewSet POST, WorkspaceViewViewSet POST, NotificationViewSet DELETE, StateViewSet GET, ModuleIssueViewSet PUT/PATCH/GET.

I have not verified each is exploitable — some may be protected by get_queryset scoping, and create/destroy on a generic mixin may fail for unrelated reasons. That verification is the work. Tracked separately rather than expanding this PR.

Summary by CodeRabbit

  • Bug Fixes

    • Improved project update authorization for PUT requests.
    • Unauthorized project updates are rejected without changing project details.
    • Workspace administrators can continue updating projects as expected.
    • PUT and PATCH requests now apply consistent authorization rules.
  • Tests

    • Added coverage for unauthorized member access and protected project updates.

… DRF

urls/project.py maps "put": "update", but ProjectViewSet never defined update,
so PUT fell through to DRF's ModelViewSet.update. The class sets no
permission_classes, so that ran under the default IsAuthenticated while
partial_update on the identical URL requires workspace or project admin.

A workspace MEMBER with no membership of a Secret project could PUT it to
network=2 (Public) and then join via the public-project API — read plus
member-level write on a project they were never in. Confirmed: an unpatched
non-member PUT returns 200 and flips network.

PUT now routes through partial_update so both verbs enforce the same rule; a
full PUT-replace is not a meaningful operation for projects.

Contract tests cover the denied PUT, that a denial writes nothing, that PUT and
PATCH reach the same verdict (the defect was that they disagreed), and a
positive control that an admin PUT still works. Fail-before verified: 3 failed /
1 passed unpatched, 4 passed patched.

Note the payload must be complete — DRF's generic update runs the serializer
with partial=False, so an incomplete body 400s on validation before
authorization differs, and the test would pass either way.

Co-authored-by: Plane AI <noreply@plane.so>
Copilot AI lite review requested due to automatic review settings August 13, 2026 11:40
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7658afef-432c-45f1-842f-938e02d95777

📥 Commits

Reviewing files that changed from the base of the PR and between d9841a5 and c484805.

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

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

ProjectViewSet now routes PUT requests through partial_update. Contract tests verify project authorization, unchanged data after rejected requests, PUT/PATCH consistency, and workspace-admin updates.

Changes

Project PUT authorization

Layer / File(s) Summary
PUT update authorization and contract coverage
apps/api/plane/app/views/project/base.py, apps/api/plane/tests/contract/app/test_project_put_authz.py
ProjectViewSet.update forwards PUT requests to partial_update. Contract tests cover unauthorized non-members, mutation prevention, PUT/PATCH agreement, and workspace-admin updates.

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

Merge Risk: ⚪ Minimal · up to c4848

This change routes project PUT requests through the same authorization path as PATCH and adds coverage for denied writes and administrator success; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: dheeru0198, pablohashescobar

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the security fix: routing ProjectViewSet PUT requests through the authorization-protected path. It is specific and related to the main change.
Description check ✅ Passed The description provides detailed context, impact, implementation details, test coverage, fail-before and patched results, and related findings. It omits the template's explicit Type of Change and Scr…
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 provides detailed context, impact, implementation details, test coverage, fail-before and patched results, and related findings. It omits the template's explicit Type of Change and Screenshots and Media headings, but the required technical information is substantially complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch secur-248/project-viewset-put-guard

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 Aug 13, 2026

Copy link
Copy Markdown

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

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.

Pull request overview

Fixes an authorization gap where PUT /workspaces/<slug>/projects/<id>/ was routed to update but ProjectViewSet did not implement update, causing DRF’s generic ModelViewSet.update (with only default IsAuthenticated) to run instead of the stricter admin checks enforced in partial_update.

Changes:

  • Add ProjectViewSet.update that delegates to partial_update so PUT and PATCH enforce identical authorization rules.
  • Add contract tests covering non-member denial, no-write-on-deny, PUT/PATCH verdict consistency, and an admin positive control.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/api/plane/app/views/project/base.py Adds update() to route PUT through the existing partial_update admin checks.
apps/api/plane/tests/contract/app/test_project_put_authz.py Adds contract/regression coverage for the PUT authorization defect and ensures denied PUTs do not mutate project state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The test module's docstring embedded the internal advisory ticket
reference directly in source. This repo is public, and an ID tying a
docstring straight to the exact authorization gap it covers hands
anyone on an unpatched fork a precise map from advisory to vulnerable
code path. Reworded the docstring to describe the invariant under
test (PUT must enforce the same authorization as PATCH) instead.

Co-authored-by: Plane AI <noreply@plane.so>
@mguptahub

Copy link
Copy Markdown
Collaborator Author

Addressed the review blocker: the test module's docstring embedded the internal ticket reference directly in source. Reworded it to describe the invariant under test instead — no ticket ID anywhere in the file now (double-checked with a repo-wide grep restricted to files this branch touches).

Old: """Contract tests for \`ProjectViewSet`` PUT authorization (SECUR-248)."""New:"""Contract tests for ``ProjectViewSet`` PUT authorization.` followed by a sentence stating the invariant (PUT must enforce the same authorization as PATCH, not fall through to DRF's generic handler under the bare default permission class), then the existing explanatory paragraphs unchanged.

Ran ruff check on the file (clean) and the full contract test module via docker compose -f docker-compose-test.yml run --rm --build api-tests pytest plane/tests/contract/app/test_project_put_authz.py -m contract -v — all 4 tests still pass, confirming the docstring change has no behavioral effect.

@github-actions

Copy link
Copy Markdown

React Doctor found 26 new issues in 25 files · 26 warnings · score 68 / 100 (Needs work) · 1 fixed · vs preview

26 warnings

core/components/core/image-picker-popover.tsx

  • ⚠️ L54 Large component is hard to read and change no-giant-component
  • ⚠️ L61 State only used in handlers rerender-state-only-in-handlers

core/components/cycles/archived-cycles/header.tsx

  • ⚠️ L24 Import from a barrel file no-barrel-import

core/components/gantt-chart/blocks/block-row.tsx

  • ⚠️ L19 Import from a barrel file no-barrel-import

core/components/gantt-chart/blocks/block.tsx

  • ⚠️ L20 Import from a barrel file no-barrel-import

core/components/gantt-chart/chart/main-content.tsx

  • ⚠️ L31 Import from a barrel file no-barrel-import

core/components/issues/issue-layouts/quick-add/root.tsx

  • ⚠️ L20 Import from a barrel file no-barrel-import

core/components/issues/peek-overview/issue-detail.tsx

  • ⚠️ L29 Import from a barrel file no-barrel-import

core/components/project-states/state-item-title.tsx

  • ⚠️ L16 Import from a barrel file no-barrel-import

core/components/workspace/sidebar/favorites/favorite-folder.tsx

  • ⚠️ L37 Import from a barrel file no-barrel-import

core/components/workspace/sidebar/favorites/favorite-items/root.tsx

  • ⚠️ L28 Import from a barrel file no-barrel-import

core/components/workspace/sidebar/favorites/favorites-menu.tsx

  • ⚠️ L34 Import from a barrel file no-barrel-import

src/breadcrumbs/breadcrumbs.tsx

  • ⚠️ L10 Import from a barrel file no-barrel-import

src/collapsible/collapsible.tsx

  • ⚠️ L104 Non-component export in component file only-export-components

src/combobox/combobox.tsx

  • ⚠️ L9 Import from a barrel file no-barrel-import

src/dropdown/common/options.tsx

  • ⚠️ L12 Import from a barrel file no-barrel-import

src/dropdown/multi-select.tsx

  • ⚠️ L15 Import from a barrel file no-barrel-import

src/dropdown/single-select.tsx

  • ⚠️ L15 Import from a barrel file no-barrel-import

src/dropdowns/context-menu/root.tsx

  • ⚠️ L12 Import from a barrel file no-barrel-import

src/dropdowns/custom-search-select.tsx

  • ⚠️ L18 Import from a barrel file no-barrel-import

src/dropdowns/custom-select.tsx

  • ⚠️ L18 Import from a barrel file no-barrel-import

src/popovers/popover.tsx

  • ⚠️ L13 Import from a barrel file no-barrel-import

src/provider/index.tsx

  • ⚠️ L9 Import from a barrel file no-barrel-import

src/scroll-area.tsx

  • ⚠️ L9 Import from a barrel file no-barrel-import

src/tabs/tabs.tsx

  • ⚠️ L11 Import from a barrel file no-barrel-import

src/tooltip/root.tsx

  • ⚠️ L9 Import from a barrel file no-barrel-import

Reviewed by React Doctor for commit c484805. See inline comments for fixes.

@mguptahub

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #9652, which supersedes this — it covers the same ProjectViewSet PUT fall-through plus every other undecorated routed verb across the URLconf (225 actions audited, 27 refused vs. this PR's single-viewset point-fix), from the same structural guard. No functionality here is lost; it's a strict subset of #9652's diff.

Thanks for the fix — the audit approach is what's landing, not the specific patch.

@mguptahub mguptahub closed this Aug 27, 2026
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.

2 participants