Skip to content
Access control Disclosed report Intermediate

Developers can create pipeline schedules on protected branches even if they don't have access to merge by creating a matching tag

A developer without merge permissions could create a pipeline schedule on a protected branch by first creating a tag with the same name and then manipulating the ref field to remove the refs/tags prefix. This allowed them to run pipelines on protected branches, bypassing branch protection rules.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 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 #2264595 by js_noob on 2023-11-26, assigned to @ngeorge1:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, as a part of the branch protection rules, developers should not be able to run or schedule pipelines on branches they don't have merge permissions to. From the docs

The schedule owner must have the Developer role. For pipelines on protected branches, the schedule owner must be allowed to merge with the branch.

However, a developer can bypass this condition.

This is a bypass of https://hackerone.com/reports/2089517

Steps to reproduce

As an owner:

  1. Create a project
  2. Create a new branch called protected
  3. Navigate to https://gitlab.com/OWNER/PROJECT/-/settings/repository#js-protected-branches-settings and set Allowed to merge and Allowed to push and merge to Maintainers on the protected branch
image.png
image.png From the original on GitLab
  1. Add a developer to the project

As the developer

  1. Navigate to https://gitlab.com/OWNER/PROJECT/-/pipeline_schedules/new
  2. Try creating a pipeline schedule on protected and verify the error
  3. Create a new tag called protected
  4. Navigate back to https://gitlab.com/OWNER/PROJECT/-/pipeline_schedules/new, create a schedule on the protected branch, and intercept the request. The body of the request should look something similar to the following
{"operationName":"createPipelineSchedule","variables":{"input":{"description":"test","cron":"5 9 * * *","cronTimezone":"Etc/GMT+12","ref":"refs/tags/v1","variables":[],"active":true,"projectPath":"jawadneeme1/poc-project-12871"}},"query":"mutation createPipelineSchedule($input: PipelineScheduleCreateInput!) {\n  pipelineScheduleCreate(input: $input) {\n    clientMutationId\n    errors\n    __typename\n  }\n}\n"}  
  1. In the ref field remove the refs/tags or refs/heads from the ref, and only keep protected
  2. Verify the success
  3. Delete the protected tag
  4. Verify that the created schedule is on the protected branch
POC
bandicam_2023-11-26_22-24-43-585.mp4 From the original on GitLab

Impact

Developers with no merge access can create pipeline schedules on protected branches.

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 application did not properly validate the ref format when creating a pipeline schedule, allowing a tag reference to be interpreted as a branch reference after removing the prefix.

What the attacker needed

Developer role in a project; Protected branch configured; Ability to create tags

How it was found

  1. As an owner, create a project and a branch called protected.
  2. Set allowed to merge and allowed to push and merge to Maintainers on the protected branch.
  3. Add a developer to the project.
  4. As the developer, try creating a pipeline schedule on the protected branch and observe the error.
  5. Create a new tag called protected.
  6. Create a schedule on the protected branch, intercept the request, and modify the ref field to remove refs/tags or refs/heads, keeping only protected.

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 meant to stop people from making changes without permission. A developer found a way to schedule pipelines on those branches by using a tag with the same name and tweaking the request. This let them run code on branches they shouldn't have access to.

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.