An attacker is able to commit to tags with the same name as protected branches, and in many areas GitLab treats the tag as a branch (ambiguous git ref)
GitLab blocked tags with the same name as the default branch but still allowed tags matching other protected branches. A developer could push such a tag and then delete the branch, causing GitLab to treat the tag as the branch and show attacker-controlled content.
GitLab
Originally disclosed on GitLab
- Fixed in 11 months
- Disclosed after 11 months
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #1947917 by js_noob on 2023-04-14, assigned to @greg:
Report | Attachments | How To Reproduce
Report
Summary
Hello team, this is a report to bypass the fix that was introduced in this issue. The fix was introduced to block any attacker from creating tags having the name of the default branch, however, an attacker can still create tags having the name of any protected branch.
Steps to reproduce
As an owner:
- Create a new project
- Create a new branch called
protected - Protect that branch and don't allow anyone to push changes to it (Settings => Repository => Protected branches)

- Add a developer to that project
As the developer:
- Clone the project locally
git clone https:...
- Checkout the protected branch
git fetch origin protected
git checkout protected
- Create a new branch with the name
new-feature
git checkout -b 'new-feature'
- Edit any changes to any file
- Commit and push the
new-featurebranch
git add .
git commit -m 'new-feature'
git push origin HEAD
- Grab the hash of the final commit using the following command
git rev-parse HEAD
- Switch back to the protected branch
git checkout protected
- Create a tag with the name of protected pointing to the latest commit of the
new-featurebranch
git tag protected HASH_FROM_STEP_10
- Push the tags to the remote
git push origin --tags
- Remove the
new-featurebranch from the remote
git push -d origin 'new-feature'
As the owner:
- From the UI navigate to https://gitlab.com/GROUP/PROJECT/-/tree/protected, and verify the changes
Video/POC
Impact
An attacker is able to change the content of any non-default protected branch file by pushing a tag with the protected branch name.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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
Root cause
Likely the fix only checked the default branch name and did not account for other protected branches, so GitLab's ambiguous ref handling let a tag shadow a branch.
Impact
An attacker could change the content shown for any non-default protected branch by pushing a tag with that branch name.
What the attacker needed
A GitLab account with developer role; a protected non-default branch exists
How it was found
- As owner, create a project and a branch called protected, then protect it.
- Add a developer to the project.
- As developer, clone the project and check out the protected branch.
- Create a new branch, make a change, commit, and push it.
- Create a tag with the protected branch name pointing to the new commit, push tags, and delete the new branch.
- As owner, visit the tree URL for the protected branch and see the changed content.
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 Git, a branch and a tag are different things, but both are just names pointing to a commit. GitLab tried to stop people from making a tag with the same name as the main branch, but forgot other protected branches. So a user could make a tag named like a protected branch, delete the real branch, and GitLab would show the tag's content as if it were the branch.
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.