Skip to content
Business logic Disclosed report Beginner

CI/CD Shared Runner Usage Quota is only counted when Shared Runners are enabled.

The shared runner quota is only counted when shared runners are enabled at job finish; toggling them off can bypass the quota.

GitLab

Originally disclosed on GitLab

  • Fixed in 5 months
  • Disclosed after 5 months

HackerOne report #1104434 by marandil on 2021-02-16, assigned to @rchan-gitlab:

Report | Attachments | How To Reproduce

Report

NOTE! Thanks for submitting a report! Please replace all the (parenthesized) sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!

Summary

Projects hosted on gitlab.com, whether public or private, can run CI jobs either using private runner instances, or using public, shared runners. Private projects are limited to a given quota of CI/CD shared runner minutes, with different numbers depending on tiers. Quota for user projects can be read under Preferences / Usage Quotas (https://gitlab.com/-/profile/usage_quotas), for groups under Group / Settings /Usage Quotas (https://gitlab.com/groups/[group-name]/-/usage_quotas). For free tier this usage quota is 400 minutes per month with extra 10$ per 1000 minutes.

This limit can be bypassed by quickly enabling and subsequently disabling shared runners for a group/project. It appears the usage quotas are only counted when a pipeline job finishes running and the shared runners are enabled.

This may also impact self-hosted GitLab instances that employ shared runners, although with much lower impact than the public instance.

Steps to reproduce
  1. Log in to GitLab as a fresh user (works also for groups and old users)
  2. Create an empty project, click on Set up CI/CD and enter any CI/CD job, e.g.:
test:  
  image: ubuntu  
  script:  
    - sleep 5m  
  1. Commit the changes. The job should start running automatically and after a couple of minutes 5/400 minutes should be visible under https://gitlab.com/-/profile/usage_quotas
  2. Open another tab and go to Project / Settings / CI/CD, expand Runners and toggle off Enable shared runners for this project.
  3. Back on the first tab, restart the job, e.g. on https://gitlab.com/[user or group]/[project]/-/jobs/[job id], the job should now be paused with a warning:

This job is stuck because you don't have any active runners that can run this job.

  1. Back on the second tab, toggle Enable shared runners for this project ON, wait for a couple of seconds (~10) and then toggle back OFF.
  2. Back on the second tab the job should be running again. After it finishes go to https://gitlab.com/-/profile/usage_quotas. It now reads 5 / Not supported minutes.

This is the simplest way to reproduce this exploit, but it can be scaled to hundreds of jobs across several pipelines.

Impact

One obvious impact is that this can cost GitLab more money than they have in budget for "free" tier users. Given how GitLab recently lowered the amount of free CI/CD minutes from 2000 to 400 (which n.b. as I noticed when doing this writeup is still not reflected in https://gitlab.com/[user]/[project]/-/settings/ci_cd) and is now charging 10$ / 1000 minutes, the potential impact of those unaccounted for minutes may be substantial.

In my brief experiments with the exploit I checked that a newly created account can start spamming CI jobs almost immediately. Runners can run quite complex jobs, act as parts of a botnet and such.

Technically the technique can be used to freely and automatically spawn a cascade of CI pipelines that would block indefinitely shared runners on self-hosted instances, even with small quotas for shared runners (think about Edu institution that allows students to host & test their projects with a limited shared runner quota, that get's blocked by a single student).

Examples

PoC project exported at https://gitlab.com/mdl-hackerone-test2/shared-runner-poc/download_export

What is the current bug behavior?

Jobs running on shared runners only contribute towards shared runners quota when "Enable shared runners for this project" option is enabled when the job runs and finishes (the option must still be enabled when the job is started, but may be disabled shortly after)

What is the expected correct behavior?

Jobs running on shared runners contribute towards shared runners quota regardless of "Enable shared runners for this project" option. In the best scenario, the time should be counted as the jobs go and they should be cancelled if the owner runs out of CI/CD minutes.

Relevant logs and/or screenshots

Attached a demo recording.

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Impact

One obvious impact is that this can cost GitLab more money than they have in budget for "free" tier users. Given how GitLab recently lowered the amount of free CI/CD minutes from 2000 to 400 (which n.b. as I noticed when doing this writeup is still not reflected in https://gitlab.com/[user]/[project]/-/settings/ci_cd) and is now charging 10$ / 1000 minutes, the potential impact of those unaccounted for minutes may be substantial.

In my brief experiments with the exploit I checked that a newly created account can start spamming CI jobs almost immediately. Runners can run quite complex jobs, act as parts of a botnet and such.

Technically the technique can be used to freely and automatically spawn a cascade of CI pipelines that would block indefinitely shared runners on self-hosted instances, even with small quotas for shared runners (think about Edu institution that allows students to host & test their projects with a limited shared runner quota, that get's blocked by a single student).

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 quota accounting only occurs when a job finishes and the shared runners setting is still enabled, so disabling it before completion skips the count.

Impact

This could cost GitLab more money than budgeted for free tier users, and on self-hosted instances it could allow blocking shared runners indefinitely.

What the attacker needed

A GitLab account; ability to create a project and CI job

The fix

The quota should be counted regardless of the shared runners setting, ideally in real time with jobs cancelled when minutes run out.

How it was found

  1. Log in to GitLab as a fresh user.
  2. Create an empty project and set up a CI/CD job that runs for a few minutes.
  3. Commit the changes and observe the job start and minutes counted.
  4. In another tab, disable shared runners for the project.
  5. Restart the job; it will be stuck due to no runners.
  6. Enable shared runners briefly, then disable again; the job resumes and finishes without counting minutes.

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.

GitLab offers free CI/CD minutes for running jobs on shared servers. There is a monthly limit. This report shows that if you turn off shared runners while a job is running, the minutes used are not counted, so you can use more than your limit without paying.

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.