Skip to content
Access control Disclosed report Intermediate

Removed author of the merge request can still edit merge request’s approval rules using API

A removed project member who authored a merge request could still edit that merge request's approval rules through the API, even though the UI correctly blocked this. This could allow the attacker to remove required approvals and merge malicious changes to a protected branch.

GitLab

Originally disclosed on GitLab

  • Fixed in 8 months
  • Disclosed after 8 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 #2980839 by theluci on 2025-02-07, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Hello, I hope you are doing well.

I found that the author of the merge request, removed from the project can still edit merge request’s approval rules using API even when the option isn’t available when using UI.

Vulnerability

According to docs, to override the merge request’s approval rules, You must have at least the Developer role in the project.

1feb-5.png
1feb-5.png From the original on GitLab

If the author of the merge request is removed from the project and tries to edit approval rules of the merge request, he can not do so using UI

1feb-6.png
1feb-6.png From the original on GitLab

Which is correct and as per the documentation.

However, the check isn’t ensured when using API.
That is, an author of the merge request, removed from the project can still override merge request’s approval rules using API contrary to documentation.

Steps to reproduce

  1. victim creates a public group victim-group and starts Ultimate trial.
  2. victim navigates to Manage --> Members,
  • victim invites victim-member as a Maintainer to victim-group
  • victim invites attacker as a Developer to victim-group
  1. victim creates a public project victim-project inside victim-group.
    (Initialize repository with a README)
  2. victim navigates to Settings --> Merge requests, scrolls down to Merge request approvals,
  • victim sets the Minimum required approvals to 2.
  • victim clicks Add approval rule and selects the following configuration,
6feb-1.png
6feb-1.png From the original on GitLab
6feb-2.png
6feb-2.png
  • victim selects the following configuration,
6feb-3.png
6feb-3.png From the original on GitLab

At this point, victim does not allow approval rules overriding and every merge request must be properly approved before being merged.

  1. attacker visits victim-project, creates a new branch another and makes some malicious changes.
  2. attacker creates a merge request from another branch to main.
  3. victim visits victim-project, navigates to Code --> Merge requests and selects the merge request. (Created in step 6)
  4. victim sets the merge request to auto-merge.

victim hopes to merge the request after the required approval criteria has been met but not yet as to investigate/review the code further.

  1. attacker visits victim-project, navigates to Code --> Merge requests, selects the merge request (Created in step 6) and marks it as Draft.
  2. victim visits victim-group, navigates to Manage --> Members and Removes attacker.
  3. victim visits victim-project, navigates to Settings --> Merge requests, scrolls down to Merge request approvals and uncheck Prevent editing approval rules in merge requests.
6feb-4.png
6feb-4.png From the original on GitLab

Now, victim allows approval rules overriding as only high role trustworthy members are in project and if required they can edit approval rules.

<------------------------------------Important----------------------------------------------->

These members already have enough permissions to visit Settings and edit approval rules if required, so giving them permission to override approval rules isn’t a security concern.
Please note that while attacker was a part of the project approval rules overriding were not allowed.

In a real-world scenario, approval rules overriding would only be allowed in a very trusting environment, where members may already have enough permission to edit approval rules from Setting if required.

Thus, for an attacker, not part of the project, to be able to edit a merge request’s approval rules is a grave security concern.

<----------------------------------------------------------------------------------------------->

  1. attacker visits https://gitlab.com/api/v4/projects/<victim-project-id>/approval_settings?target_branch=main
  • attacker notes the id of All Members
7feb-1.png
7feb-1.png From the original on GitLab
  1. attacker visits victim-project, navigates to Code --> Merge requests and selects the merge request. (Created in step 6)
  2. attacker clicks on Edit and unchecks Draft
6feb-5.png
6feb-5.png From the original on GitLab
  1. attacker clicks on Save changes but intercepts the request.
  2. attacker adds the following to the body of the request,
&merge_request%5Bapproval_rules_attributes%5D%5B%5D%5Bapproval_project_rule_id%5D=<ID_All_Members>&merge_request%5Bapproval_rules_attributes%5D%5B%5D%5Bapprovals_required%5D=0&merge_request%5Bapproval_rules_attributes%5D%5B%5D%5Bname%5D=&merge_request%5Bapproval_rules_attributes%5D%5B%5D%5Buser_ids%5D%5B%5D=&merge_request%5Bapproval_rules_attributes%5D%5B%5D%5Bgroup_ids%5D%5B%5D=  

Please be sure to replace ID_All_Members with the ID noted in step 12.

<redacted>

  1. attacker forwards the request.

attacker is able to edit approval rules using API despite not being a part of the project.

  1. Merge request is merged.

POC

<redactec>

Output of checks

This bug happens on GitLab.com (Probably on instance too)

Impact

An author of the merge request, removed from the project can still override merge request’s approval rules using API (even though the option isn’t available when using UI) contrary to documentation, which in worst-case scenario may merge malicious changes to the protected branch.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

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

Root cause

Likely the API endpoint for updating a merge request did not check whether the user still had permission to edit approval rules, while the UI did enforce that check.

Impact

The attacker could override approval rules and potentially merge malicious changes to a protected branch, bypassing required approvals.

What the attacker needed

Attacker is a project member (Developer); attacker authors a merge request; victim enables approval rule overriding; attacker is removed from project

How it was found

  1. Victim creates a group and project, invites attacker as Developer, and configures merge request approvals with a minimum of 2 and overriding disabled.
  2. Attacker creates a branch with malicious changes and opens a merge request to main.
  3. Victim sets the merge request to auto-merge.
  4. Attacker marks the merge request as Draft.
  5. Victim removes attacker from the group and unchecks 'Prevent editing approval rules in merge requests', allowing overriding.
  6. Attacker uses the API to get the ID of the 'All Members' approval rule, then intercepts the request to save changes on the merge request and adds parameters to set approvals_required to 0 for that rule, and forwards it.

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, merge requests often need a certain number of approvals before they can be merged. The person who wrote the merge request should not be able to change those approval rules, especially after they have been removed from the project. Here, the website interface stopped them, but the API (a way for programs to talk to GitLab) did not, so they could still change the rules and get their code merged without proper review.

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.