Skip to content
Access control Disclosed report Intermediate

A developer can disclose group/project protected CI/CD vars using MRs approvals conflicts broken logic

A developer could bypass merge request approval rules and merge code without the required approvals, allowing them to run code on a protected branch and disclose protected CI/CD variables.

GitLab

Originally disclosed on GitLab

  • Fixed in 37 days
  • Disclosed after 37 days

⚠️ 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 #2078069 by js_noob on 2023-07-20, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, for a developer to be able to disclose the protected CI/CD vars he should have to merge and push access to a project. However, even without those, there is some broken logic in the MRs approvals where it allows him to bypass all approvals logic and merge his evil code which allows him to disclose the vars.

Steps to reproduce

As an owner:

  1. Create a new group and apply the ultimate trial to it
  2. Add a developer to the group
  3. Add a protected var in that group, Group Settings => CI/CD => Variables
image.png
image.png From the original on GitLab
  1. Create a new project in that group, and add a .gitlab-ci.yml file with the following content
build:  
    script:  
        - echo "This is safe..."  
  1. Allow developers to merge MRs, Project Settings -=> Repository => Protected branches
image.png
image.png From the original on GitLab
  1. Add MR approval rule to require 2 approvals before merging any MR, Project Settings => Merge requests => Merge request approvals
image.png
image.png From the original on GitLab
  1. On the same page, make sure Prevent approval by author is checked. Now no MRs should be merged unless approved by both members, right?

As the developer:

  1. Edit .gitlab-ci.yml to match the following
build:  
    script:  
        - echo "This is safe..."  
        - echo $VAR  
  1. Create a merge request, and verify that you can merge it (knowing that the logic that should be here, is that now it should require 1 approval)
  2. Merge it, navigate to the pipeline logs, and verify that the protected variable is disclosed

The developer in this case is trusted to merge MRs, that are approved by the owner (requires 2 approvals dev + owner), however, he was able to bypass this and merge a MR without the owner's approval, allowing him to run any code on protected branches (main in this case).

The expected logic, in this case, is requiring 1 approval not 2, as the other member that should approve is the MR author, while here it required 0 approvals.

Examples/POC
bandicam_2023-07-20_21-21-47-081.mp4 From the original on GitLab
Output of checks

This bug happens on GitLab.com

Impact

A developer can disclose project/group protected CI/CD variables.

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 a logic error in merge request approval rules where the system failed to require the correct number of approvals when the author is also a developer with merge rights.

Impact

A developer could disclose project or group protected CI/CD variables by merging code without required approvals.

What the attacker needed

A GitLab group with Ultimate trial; developer role in the group; protected CI/CD variable set; merge request approvals configured

How it was found

  1. As owner, create a group, add a developer, and add a protected CI/CD variable.
  2. Create a project in the group with a basic CI configuration.
  3. Allow developers to merge merge requests and set an approval rule requiring two approvals with 'Prevent approval by author' checked.
  4. As the developer, edit the CI configuration to echo the protected variable.
  5. Create a merge request and merge it without any approvals.
  6. View the pipeline logs to see the protected variable disclosed.

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 CI/CD variables are secret values used in pipelines. Normally, only trusted users can merge code to protected branches. Here, a developer with limited rights found a way to merge their own code without the required approvals, so they could print the secret variable in the pipeline logs.

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.