Skip to content
Access control Disclosed report Intermediate

Able to Delete Source Branch of MR

A member of the target project could set the 'remove source branch after merge' option on a merge request from a fork, which is not possible through the web interface. This allowed them to delete the source branch in the fork without the fork owner's consent.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 months

HackerOne report #633386 by ngalog on 2019-07-02, assigned to estrike:

Summary

For every MR from fork project to original project, there are two gruops of people can make changes.

  1. The MR author, i.e. fork project developer/maintainer
  2. The MR target project's developer/maintainer, i.e. original project developer/maintainer

Normally, people in no.1 is only able to change the MR's metadata such as of title/description html/remove source branch after merge etc, but not the label or milestones etc.

People in no.2 is only able to change the MR's label, milestones, merge when pipeline succeed etc, but not remove source branch after merge.

I found that, member of original project, is able to change the setting of remove source branch after merge in gitlab API, which is not possible in Gitlab UI.

Impact

MR target project member could delete source project's branch without their consent/proper permission

Steps to reproduce

  • As user A, create a public project with a random name such as projectZero
  • As user B, fork projectZero, create a new file, then create a new branch, then submit a MR to projectZero, remembe the Delete source branch when merge request is accepted. is UNCHECKED
  • As user A, prepare your gitlab API scope token, and issue below request
PUT /api/v4/projects/:project_id_of_original_project/merge_requests/:mr_iid HTTP/1.1  
Host: gitlab.com  
private-token: YOUR_TOKEN  
Content-Length: 136  
content-type:application/json


{"should_remove_source_branch":true,"remove_source_branch":true,"force_remove_source_branch":true}  
PUT /api/v4/projects/:project_id_of_original_project/merge_requests/:mr_iid/merge HTTP/1.1  
Host: gitlab.com  
private-token: YOUR_TOKEN  
Content-Length: 136  
content-type:application/json


{"should_remove_source_branch":true,"remove_source_branch":true,"force_remove_source_branch":true}  
  • Then as user B, you should notice your MR source branch is remoevd without your consent.

Examples

reproducible on gitlab.com

Impact

MR source branch could be deleted by target project's member without proper authorization/permission

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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

A member of the target project could delete the source branch in the fork without the fork owner's permission.

What the attacker needed

GitLab account (user A); GitLab account (user B); User A is member of original project; User B creates MR from fork

How it was found

  1. As user A, create a public project.
  2. As user B, fork the project, create a new file and branch, then submit a merge request to the original project with 'Delete source branch when merge request is accepted' unchecked.
  3. As user A, obtain a GitLab API token and send a PUT request to the merge request endpoint with parameters to enable source branch removal.
  4. As user A, send another PUT request to the merge endpoint with the same parameters.
  5. As user B, observe that the source branch has been removed without consent.

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, when you propose changes from your copy of a project (a fork) to the original, you create a merge request. Normally, only you can decide whether your branch gets deleted after the merge. This report shows that someone on the original project could secretly turn on that deletion setting using the programming interface (API), even though the website doesn't offer that option.

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.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.