Skip to content
Business logic Disclosed report Intermediate

Force pipelines to not have access to protected variables and will likely fail

A developer could create a branch named refs/heads/main that GitLab treated as the protected main branch, causing subsequent pipelines on main to lose access to protected CI/CD variables and likely fail.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 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 #1932805 by js_noob on 2023-04-03, assigned to @fvpotvin:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, a developer can force all pipelines from the main branch to not have access to protected CI/CD variables and will likely force them to fail.

Steps to reproduce

As an owner do the following:

  1. Create a project
  2. Add a couple of variables /-/settings/ci_cd lets call them VAR_1 and VAR_2
  3. Add .gitlab-ci.yml file containing the following:
YML
image: node:latest

stages:    
  - build

build-job:    
  stage: build    
  script:    
    - echo $VAR_1  
    - cat $VAR_2  
  1. Add any commit and navigate to the pipeline logs and verify that the variables are logged
  2. Add a developer member

As the developer do the following:

  1. Clone the repo locally git clone <repo>
  2. Create a new branch named refs/heads/main; git checkout -b 'refs/heads/main'
  3. Delete .gitlab-ci.yml file and commit the changes
  4. Push the branch to remote git push origin HEAD

As an owner do the following:

  1. Add any changes and commit
  2. Navigate to the pipeline logs and verify that the vars are empty and not logged
Video/POC
bandicam_2023-04-03_21-24-20-196.mp4 From the original on GitLab

Impact

Pipelines on main will not have access to protected variables leading them to fail.

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 GitLab did not properly validate branch names, allowing a branch named refs/heads/main to be treated as the protected main branch.

Impact

Pipelines on main will not have access to protected variables, likely causing them to fail.

What the attacker needed

Developer role in project; protected variables configured

How it was found

  1. As owner, create a project and add CI/CD variables.
  2. Add a .gitlab-ci.yml that echoes the variables and run a pipeline to confirm they are logged.
  3. Add a developer member.
  4. As developer, clone the repo and create a branch named refs/heads/main.
  5. Delete .gitlab-ci.yml, commit, and push the branch.
  6. As owner, commit a change and check pipeline logs; variables are empty.

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 variables are secret values only available to pipelines running on protected branches like main. A developer could create a branch with a special name that confused GitLab into thinking it was the real main branch, so later pipelines on main could not see those secrets and would break.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.