Every authenticated user can push into public non-protected branches
Any authenticated GitLab user could push to public repositories if a branch was not protected. An attacker could push or force-push commits into other users' repositories.
GitLab
Originally disclosed on GitLab
- Fixed in 31 days
- Disclosed after 31 days
HackerOne report #1049064 by aarani on 2020-12-02, assigned to @rchan-gitlab:
Report | How To Reproduce
Report
> 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
There is a severe security bug in Gitlab which lets any authenticated user push to public repositories if the branch isn't protected.
"Protected" status is supposed to keep PROJECT MEMBERS from directly pushing into specific branches instead of using merge requests and removing it shouldn't let all users push into a repository.
There are times when people need to unprotect a branch to allow force-pushing temporarily, for example, but still only to members of the repo, not to every gitlab.com user.
Steps to reproduce
1- Create a new project
2- Initialize a repository with you git client
3- Commit a README file into the project to create a master branch
4- Push it into your new project with your git client
5- Go to the repo settings -> protected branches: the master branch is protected by default, remove the protected status
Impact
Any gitlab.com user can push into any public repository unless that branch is protected
What is the current bug behavior?
Everyone with a GitLab account can push into your new public project
What is the expected correct behavior?
It should only let project members (maintainers and/or mem) push/force-push into that branch
Output of checks
This bug happens on GitLab.com
Impact
An attacker can with zero skills push and force-push commits into users' repositories
How To Reproduce
Please add reproducibility information to this section:
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
What the attacker needed
A GitLab account; target public repository with unprotected branch
How it was found
- Create a new project
- Initialise a repository with your git client
- Commit a README file to create a master branch
- Push it to the new project
- Go to repo settings, protected branches, and remove protection from master
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.
In GitLab, a branch is a line of development. Normally, only project members should be able to add code to a branch. This bug meant that anyone with a GitLab account could add or overwrite code in a public project if the branch was not marked as protected.
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.