fix(tasks): require owner permission to cancel a task via REST#308
Merged
Conversation
POST /tasks/{task_id}/cancel authorized the `update` permission, which editors
hold, so a task editor who is not the owner could cancel a task through the REST
route. Cancellation is owner-only — the RPC task/cancel path already checks the
`cancel` action — so the two entry points disagreed. Align the REST route to
check `cancel`. The sibling lifecycle routes (complete/fail/terminate/timeout)
intentionally keep `update`.
Adds a unit test pinning the REST cancel route to the `cancel` action.
rpatel-scale
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
POST /tasks/{task_id}/cancelauthorizesAuthorizedOperationType.update. Editors holdupdate, so a task editor who is not the owner can cancel a task through the REST route. Cancellation is intended to be owner-only.The RPC
task/cancelpath already authorizes the owner-onlycancelaction, so the two entry points to the same operation disagreed.Fix
Authorize
cancelon the REST route, matching the RPC path and the schema. The sibling lifecycle routes (complete/fail/terminate/timeout) intentionally keepupdate— those are state transitions, not the owner-only cancel.Tests
Adds a unit test pinning the REST cancel route to the
cancelaction (mirrors the existing per-RPC operation-routing tests). End-to-end behavioral coverage lives in the authorization e2e suite.Greptile Summary
This PR fixes a privilege escalation bug in the REST
POST /tasks/{task_id}/cancelendpoint where it previously authorizedupdate(allowing editors), but cancellation is owner-only. The fix aligns the REST route with the RPCtask/cancelpath by switching toAuthorizedOperationType.cancel.tasks.py: Changescancel_task'sDAuthorizedIdcall fromAuthorizedOperationType.updatetoAuthorizedOperationType.cancel, adding a clarifying comment about the intent.test_tasks_authz.py: AddsTestRestCancelRouteRequiresOwner— a unit test that introspects the function signature to assert the dependency checkscancel, mirroring the existing per-RPC routing tests.Confidence Score: 5/5
Safe to merge — the change is a one-line auth operation swap on a single route, and the new test directly pins the expected behavior.
The change is minimal and surgical: one enum value replaced in one route, with a well-scoped unit test that introspects the function signature at test time to verify the correct operation is wired. The sibling lifecycle routes (complete/fail/terminate/timeout) are intentionally left on update and are unaffected. The RPC path already used cancel and is also untouched. No edge cases, no new dependencies, no schema changes.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant REST as REST POST /tasks/{id}/cancel participant RPC as RPC task/cancel participant Authz as Authorization Service Note over REST,Authz: Before this PR (bug) Client->>REST: "POST /tasks/{id}/cancel" REST->>Authz: check(task, update) editors allowed Authz-->>REST: authorized (editor or owner) REST-->>Client: task canceled Note over REST,Authz: After this PR (fix) Client->>REST: "POST /tasks/{id}/cancel" REST->>Authz: check(task, cancel) owner-only Authz-->>REST: authorized (owner only) REST-->>Client: task canceled Client->>RPC: task/cancel RPC->>Authz: check(task, cancel) owner-only (unchanged) Authz-->>RPC: authorized (owner only) RPC-->>Client: task canceledReviews (1): Last reviewed commit: "fix(tasks): require owner permission to ..." | Re-trigger Greptile