Skip to content
Access control Disclosed report Intermediate

Backend: Pipelines will not have access to protected variables and will likely fail when using tags

A developer could create a tag named like the main branch, causing pipelines on the main branch to lose access to protected CI/CD variables and likely fail. This could also cause a denial of service by blocking owners from deleting the malicious tag.

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 #2055158 by js_noob on 2023-07-07, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

This seems to be a bypass of https://gitlab.com/gitlab-org/gitlab/-/issues/406843

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. This is similar to #1932805, I believe this is a different root cause, as the original is fixed.

Note: I reported this earlier in #1932805 but it was closed as duplicate on the above report, GitLab team mentioned that I re-open that report if the original was fixed and the issue persists, obviously I can't re-open reports so I am reporting it as a new report.

Steps to reproduce

As an owner:

  1. Create a new project
  2. Add a protected CI/CD variable
  3. Add a .gitlab-ci.yml with the following content
PLAINTEXT
image: node:latest

stages:  
  - build

build-job:  
  stage: build    
  script:    
    - echo $VAR  
  1. Watch the pipeline logs and verify that the variables is printed
  2. Add a developer to the project

As the developer:

  1. Clone the project locally
  2. Delete the .gitlab-ci.yml file
  3. Commit the changes
PLAINTEXT
git add .    
git commit -m 'delete ci-cd'   
  1. Grab the hash of the final commit using the following command
PLAINTEXT
git rev-parse HEAD  
  1. Create a tag with the name of refs/heads/main pointing to the latest commit
PLAINTEXT
git tag 'refs/heads/main' HASH_FROM_STEP_9  
  1. Push the tags to the remote
PLAINTEXT
git push origin --tags   

As the owner:

  1. Run a new pipeline and verify that the var is not printed
Video/POC

Deleted as video does not work

Impact

Pipelines on main will not have access to protected variables leading them to fail, this will also cause DOS which blocks owners from deleting this malicious tag.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 system did not properly distinguish between a branch and a tag with the same name when determining if a pipeline runs on a protected branch.

Impact

Pipelines on main will not have access to protected variables, likely causing them to fail, and this could also cause a denial of service by blocking owners from deleting the malicious tag.

What the attacker needed

Developer role in project; ability to push tags

How it was found

  1. As owner, create a project and add a protected CI/CD variable.
  2. Add a .gitlab-ci.yml that echoes the variable and verify it prints in pipeline logs.
  3. Add a developer to the project.
  4. As developer, clone the project, delete .gitlab-ci.yml, and commit.
  5. Create a tag named refs/heads/main pointing to the latest commit and push tags.
  6. As owner, run a new pipeline and verify the variable is not printed.

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 developer could create a tag named like the main branch, after which pipelines on main no longer had the protected variables and likely failed.

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.