Skip to content
Access control Disclosed report Intermediate

Developer can retry pipelines and have them running on parent project despite having `ci_allow_fork_pipelines_to_run_in_parent_project` disabled

A developer could retry a previously created merge request pipeline and have it run in the context of the parent project, even after the setting that allows fork pipelines to run in the parent project was disabled. This could let the developer execute code in the parent project's CI environment.

GitLab

Originally disclosed on GitLab

  • Fixed in 44 days
  • Disclosed after 44 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 #2073382 by js_noob on 2023-07-17, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, a project owner can allow/disallow merge request pipelines originating from forks to tun in the context of the parent (his project), you can refer to the docs. However, after disabling this, using ci_allow_fork_pipelines_to_run_in_parent_project, a user (not owner) can still retry (i.e. run) previous pipelines that were originated from his fork in the context of the parent project.

Steps to reproduce

As an owner:

  1. Create a new group and apply the ultimate trial to it
  2. Create a project in that group, and add a .gitlab-ci.yml file with the following content
build:  
  script:  
      - echo "Building app..."

validate-merge-request:  
  script:  
    - echo "Validating merge request..."  
  only:  
    - merge_requests  
  1. Give developers access to merge on the main branch, Project Settings => Repository => Protected branches
image.png
image.png From the original on GitLab
  1. Invite another user to the group/project (both work) as a developer

As the developer:

  1. Fork that project into your namespace, edit .gitlab-ci.yml, and let it match the following
build:  
  script:  
      - echo "Building app..."

validate-merge-request:  
  script:  
    - echo "This is added is the fork..."  
    - echo "Validating merge request..."  
  only:  
    - merge_requests  
  1. Create a merge request from your project but with a target branch as the main of the project created in step 2
  2. After creating a merge request, navigate back to your project, and add any change
  3. Navigate back to the created merge request, navigate to the pipelines tab, and verify the existence of the Run pipeline button
image.png
image.png From the original on GitLab
  1. Press it, and verify that a pipeline is run in the context of the parent project

As the owner:

  1. Disable ci_allow_fork_pipelines_to_run_in_parent_project by sending the following request (you can create PAT https://gitlab.com/-/profile/personal_access_tokens)
curl --request PUT --header "PRIVATE-TOKEN: PAT" --url 'https://gitlab.com/api/v4/projects/PROJECT_ID' --data "ci_allow_fork_pipelines_to_run_in_parent_project=false"  

As the developer:

  1. Repeat step 9, but now verify that the pipeline is running in the context of the fork project
  2. Navigate to the pipeline created in step 9, and retry it manually
  3. Verify that it is running in the context of the parent
Examples/POC
bandicam_2023-07-17_22-05-29-632.mp4 From the original on GitLab
What is the current bug behavior?

Retried pipelines run in the context of the parent project.

What is the expected correct behavior?

Retried pipelines should run in the context of the forked project if ci_allow_fork_pipelines_to_run_in_parent_project is disabled.

Output of checks

This bug happens on GitLab.com

Impact

A developer can run pipelines in the context of the parent project despite having ci_allow_fork_pipelines_to_run_in_parent_project disabled.

Proposal

Documentation updates to indicate that old pipelines will run under the same settings for which they were created under.

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 retry action does not re-check the current project setting and instead uses the original pipeline's context.

Impact

A developer can run pipelines in the parent project's context despite the setting being disabled.

What the attacker needed

A GitLab account; developer role in a project; ability to fork the project; ability to create merge requests

The fix

The report suggests documenting that old pipelines will run under the same settings for which they were created, rather than changing the behaviour.

How it was found

  1. As an owner, create a group and project with a CI configuration that includes a merge request job.
  2. Invite another user as a developer.
  3. As the developer, fork the project and modify the CI configuration.
  4. Create a merge request from the fork to the parent project's main branch.
  5. In the fork project, add a change and then navigate to the merge request's pipelines tab and run the pipeline.
  6. As the owner, disable the setting that allows fork pipelines to run in the parent project.

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.

A project owner can allow or disallow fork merge request pipelines running in the parent project. The report shows old pipelines can still be retried and run in the parent context after the setting is disabled.

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.