Scope run lookup in RunsController to the nested task - #1564
Merged
Merged
Conversation
RunsController#set_run loaded the Run by id alone, ignoring the task_id route segment. Applications using MaintenanceTasks.parent_controller to authorize access per Task based on params[:task_id] could be bypassed by pairing an allowed task_id with the id of another Task's Run, allowing that Run to be paused, cancelled or resumed. Look up the Run by both id and task_name so that mismatched requests respond with 404, and document that params[:task_id] can be relied upon. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
nvasilevski
approved these changes
Sep 28, 2026
hmcguire-shopify
approved these changes
Sep 28, 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.
RunsController#set_runlooked up the Run byidalone and ignored thetask_idin the URL, soPOST /tasks/:task_id/runs/:id/{pause,cancel,resume}could act on a Run that belongs to a different Task. Apps that useMaintenanceTasks.parent_controllerto authorize per Task based onparams[:task_id]could be bypassed this way: a user allowed one Task could pause, cancel or resume another Task's Run by putting its id in the URL.This PR looks up the Run by both
idandtask_name, so a Task/Run mismatch now responds with 404, the same scopingTaskDataShow#runsalready uses to list a Task's Runs. It adds controller tests for all three actions, and the cross-task tests fail without the fix. It also adds a note to the README's parent controller section saying authorization logic can rely onparams[:task_id]for run actions.