Set of previously created Deploy Keys exist for a project
A newly created GitLab repository displayed a set of pre-existing deploy keys that were not created for that repository. An attacker with access to the repository could enable one of these keys, gaining at least read access to the repository.
GitLab
Originally disclosed on GitLab
- Fixed in 21 hours
- Disclosed after 21 hours
HackerOne report #834414 by ejohnso49 on 2020-03-30, assigned to @vdesousa:
NOTE! Thanks for submitting a report! Please replace all the (parenthesized) sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!
Summary
Repos have a consistent set of previously created publicly accessible deploy keys despite the repo being newly created after the deploy keys in question. The keys show creation dates ranging from 06/18/2015 1:07PM PDT to 03/27/2017 10:53am PDT. Sometimes one key is listed as privately accessible.
Steps to reproduce
(Step-by-step guide to reproduce the issue, including:)
Tested with both my existing Gitlab account and a newly created account as of 3/30/2020.
- Sign in with account credentials
- Create a new repo
- Navigate to repositories Settings -> CI/CD Settings
- Scroll down to Deploy Keys
- Expand Deploy Keys section
- Select Publicly Accessible Deploy Keys
- Observe deploy keys populated in the table despite none of these keys having been created for this repository.
Impact
(Summarize the impact on users)
If these keys are enabled, the holder of these keys would have at least read access and possibly write access, if the key's settings are modified, to any repo.
Examples
https://gitlab.com/ejohnso49_test/test_project/-/settings/ci_cd
What is the current bug behavior?
(What actually happens, include relevant screenshots, API results, or complete HTTP requests)
A static set of existing deploy keys are returned for the new repo. Sometimes all keys are in the publicly accessible category, sometimes a single key is in the privately accessible category.
The keys are returned in response to the following HTTP request: https://gitlab.com/ejohnso49_test/test_project/-/deploy_keys
Attached is an HAR saved from Firefox developer tools, the JSON response of the deploy_keys request, and two screenshots displaying the deploy keys being associated with the newly created repo.
What is the expected correct behavior?
The newly created repo should have zero deploy keys associated with it.
Relevant logs and/or screenshots
Output of checks
This bug happens on Gitlab.com
Results of GitLab environment info
Impact
I am unable to determine if this behavior occurs on accounts above the Free-tier. Assuming that the webpage is displaying data truthfully, a malicious user with access to a repo could enable any one of these keys as a deploy key. At this point anyone in possession of the enabled deploy key has at least read access to the repository. From my observations, no email notifications/alerts are generated from these actions, so potentially private repo data could easily be exfiltrated. If the key was enabled with write access, then anyone in possession of the key could potentially modify the repository as well, although I am unsure of how any branch protection, etc would interact with this. Additionally, it is not possible to disable/remove these keys from the project.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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
Impact
If these keys are enabled, the holder of these keys would have at least read access and possibly write access, if the key's settings are modified, to any repo.
What the attacker needed
A GitLab account; ability to create a repository
How it was found
- Sign in with account credentials
- Create a new repo
- Navigate to repositories Settings -> CI/CD Settings
- Scroll down to Deploy Keys
- Expand Deploy Keys section
- Select Publicly Accessible Deploy Keys
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.
Deploy keys are SSH keys that allow access to a repository. The report found that new repositories showed old keys that didn't belong to them, so someone could turn on one of those keys and get access to the code.
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.