fix: add authorization checks to XML-RPC stop() endpoints#282
Open
Zinkelburger wants to merge 1 commit intobeaker-project:python-3from
Open
fix: add authorization checks to XML-RPC stop() endpoints#282Zinkelburger wants to merge 1 commit intobeaker-project:python-3from
Zinkelburger wants to merge 1 commit intobeaker-project:python-3from
Conversation
|
Failed to load packit config file: For more info, please check out the documentation or contact the Packit team. You can also use our CLI command |
135ce1d to
0e695ed
Compare
Collaborator
|
You probably want to target the |
The XML-RPC methods jobs.stop(), recipesets.stop(), recipes.stop(), and recipetasks.stop() only required authentication (not_anonymous) but did not verify that the caller owns the job or has the stop_task permission. This allowed any authenticated user to cancel any other user's job by calling these endpoints directly, bypassing the can_stop() check enforced by taskactions.stop(). Add can_stop(identity.current.user) checks to all four endpoints, matching the authorization already present in taskactions.stop() and the REST API (POST /jobs/<id>/status). Lab controllers are unaffected because they authenticate with the stop_task permission, which can_stop() already permits. Made-with: Cursor
0e695ed to
53dbff1
Compare
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.
Summary
The XML-RPC methods
jobs.stop(),recipesets.stop(),recipes.stop(), andrecipetasks.stop()only require authentication (identity.not_anonymous()) but do not verify that the caller owns the job or has thestop_taskpermission. This allows any authenticated user to cancel any other user's job by calling these endpoints directly, bypassing thecan_stop()check enforced by the user-facingtaskactions.stop()and the REST API (POST /jobs/<id>/status).Proof
Tested non-destructively against beaker.engineering.redhat.com using a finished job (J:12143204) owned by
lzachar, called asanbernal:Same user, same job —
taskactions.stopcorrectly denies access whilejobs.stopallows it through. Since the target job was already finished,cancel()was a no-op and no state was modified.Fix
Adds
can_stop(identity.current.user)checks to all four endpoints, matching the authorization already present intaskactions.stop(). Lab controllers are unaffected because they authenticate with thestop_taskpermission, whichcan_stop()already permits.Files changed
Server/bkr/server/jobs.py—Jobs.stop()Server/bkr/server/recipesets.py—RecipeSets.stop()Server/bkr/server/recipes.py—Recipes.stop()Server/bkr/server/recipetasks.py—RecipeTasks.stop()IntegrationTests/.../test_job_cancel_authz.py— regression tests for all four endpoints