Skip to content
Info disclosure Disclosed report Intermediate

Webhook token leaked in project exports allowing to trigger CI pipeline

The project export for a GitHub-connected repository included the external webhook token, which is used to authenticate pipeline trigger requests. Anyone with the export could forge a valid signature and trigger new CI pipelines, potentially causing a denial of service.

GitLab

Originally disclosed on GitLab

  • Fixed in 2.1 years
  • Disclosed after 2.1 years

HackerOne report #698068 by xanbanx on 2019-09-19, assigned to @jritchey:

Hi GitLab Security Team,

Summary

When exporting a Github connect repository within GitLab, the project export contains the external_webhook_token. This token allows anyone in possession to forge authentic requests to trigger a CI pipeline within GitLab although the person might not be a project member anymore.

Steps to reproduce

Tested on GitLab Enterprise Edition 12.3.0-pre 32dae28364b

Before, create a Github account, create a project there, and push a valid .gitlab-ci.yml file.

  1. Create a new project. Chose CI/CD for external repo to import a project
  2. Chose Github under Connect repositories from
  3. Enter your personal access token from your GitHub account where you want to import the project from
  4. Select the project you created before Github for sync
  5. After importing the project, goto https://example.gitlab.com/<namespace>/<project>/edit and export the project
  6. Download the project archive, extract it, and inspect the containing project.json
JSON
...  
    "jobs_cache_index": null,  
    "external_authorization_classification_label": "",  
    "external_webhook_token": "hcnPbsfximlueXxaaIkg",  
    "pages_https_only": true,  
    "merge_requests_author_approval": null,  
...  

Note, this is a fake token for the report.

When looking in the code one observes the request POST :id/mirror/pull in https://gitlab.com/gitlab-org/gitlab/blob/master/ee/lib/api/project_mirror.rb#L59. This request is used to trigger a new pipeline for a Github connected repository. This request uses the X-Hub-Signature header to authenticate the request to create the pipeline. This signature is computed by computing an HMAC over the request data using external_webhook_token as the key.

By being in possession of external_webhook_token it means that you craft a request and forge a valid X-Hub-Signature to create a new pipeline. So anyone, who can download the project can later on, when for example he is not a project member anymore, craft such a request and thereby trigger a pipeline.

Impact

The external external_webhook_token is exported. This allows anyone in possession of this token to forge a valid POST request to trigger a new CI pipeline. In the worst case, an attacker can possibly create thousands of CI pipelines and thus DoS the CI infrastructure.

What is the current bug behavior?

The project export contains external_webhook_token. This allows anyone to forge a POST request to start a new pipeline.

What is the expected correct behavior?

Do not include the external_webhook_token in the project export. Anyway, it is not useful because this secret is bound to one specific webhook at Github, which still points to the original GitLab project. Importing the project to a different namespace or different GitLab instance would therefore make this token not working anymore.

Output of checks

This bug happens on GitLab.com

Best regards,
Xanbanx

Impact

See above.

Implementation plan

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

The project export configuration did not exclude the external webhook token from the exported attributes.

Impact

Anyone with the token could forge a valid request to trigger a new CI pipeline, and in the worst case an attacker could create thousands of pipelines and cause a denial of service on the CI infrastructure.

What the attacker needed

Access to a project export; GitHub-connected project

The fix

The external webhook token should be excluded from project exports, and the implementation plan shows it was added to excluded attributes and removed from safe model attributes.

How it was found

  1. Create a GitHub account, a project there, and push a valid .gitlab-ci.yml file.
  2. In GitLab, create a new project and choose CI/CD for external repo.
  3. Select GitHub under Connect repositories from and enter a GitHub personal access token.
  4. Select the GitHub project to sync.
  5. After import, go to the project edit page and export the project.
  6. Download and extract the archive, then inspect project.json to find the external_webhook_token.

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.

When you connect a GitHub project to GitLab, GitLab uses a secret token to verify that requests to start a pipeline really come from GitHub. This report found that the secret token was included in the project export file, so anyone who downloaded the export could use it to pretend to be GitHub and start pipelines. That could let someone who is no longer a member still trigger jobs, possibly many at once.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.