Delete a registered runner as unauthorised user
A project maintainer in one project could delete a runner registered in a different project by reading the runner's authentication token from an API response. This allowed an unauthorised user to delete a registered runner they did not own.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #767493 by ashish_r_padelkar on 2020-01-03, assigned to @jeremymatos:
Summary
Hello,
This #685239 is fixed as per latest security release here https://about.gitlab.com/blog/2020/01/02/security-release-gitlab-12-6-2-released/ which is basically updating and removing runners as maintainers but this issue is different.
In this case, you as a project maintainer is able to delete registered runner in different project when you don't have rights to do it. This happens when runner is registered by user in separate project and is enabled in project where you have maintainers rights. You then as a project maintainer just have permissions to pause or enable/disable that runner within that project in UI. However, using below API, you can delete this registered runner from different project where you dont have rights.
curl --request DELETE "https://gitlab.example.com/api/v4/runners" --form "token=<authentication_token>"
Steps to reproduce
- Create a group and 2 projects within it
Project1&Project2. - As a project maintainer, register a runner in
Project1. - When you navigate to
Project2, you have the option to enable it ( as you created in project1). - Enable this runner in
Project2. - Add one more user as project maintainer in
Project2 - Login as above user now i.e maintainer in
Project2. - Go to https://gitlab.com/<GroupName>/<ProjectName>/-/settings/ci_cd#js-runners-settings. You will see that you can either pause or disable the runner. You will not see
Remove Runneroption here because this runner is just registered in different project (Project1)where you don't have access. - Now just visit the API
https://gitlab.com/api/v4/runners/<ID>. You should see the ID in page itself. - In response, you should see the value of
tokenfor this runner . Just copy it and use it in below API to delete this registered runner
curl --request DELETE "https://gitlab.com/api/v4/runners" --form "token=<Token_from_above_response>"
What is the current bug behavior?
Allows unauthorised users to delete registered runner
What is the expected correct behavior?
In my opinion, token value should not be exposed to users in above situations.
Output of checks
This bug happens on GitLab.com and might be on omnibus installations too!
Regards,
Ashish
Impact
Allows unauthorised delete of registered token
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the API exposed the runner's authentication token to any user who could view the runner in a project, without checking that the user had permission to manage the runner in its owning project.
Impact
An unauthorised user could delete a registered runner they do not have rights over.
What the attacker needed
A GitLab account; maintainer role in a project; runner enabled in that project
The fix
The token value should not be exposed to users who do not have permission to manage the runner in its owning project.
How it was found
- Create a group with two projects, Project1 and Project2.
- As a project maintainer, register a runner in Project1.
- Enable that runner in Project2.
- Add a second user as a maintainer of Project2 and log in as that user.
- Visit the API endpoint for the runner ID to obtain its token.
- Use the token to send a DELETE request to the runners API and delete the runner.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A runner is a small program that runs jobs for a project. The report shows that a user with limited rights in one project could see a secret token for a runner that belonged to another project, and then use that token to delete the runner.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.