Skip to content
Info disclosure Disclosed report Intermediate

Maintainer can leak Datadog API key by changing integration URL

The Datadog integration in GitLab did not clear the stored API key when the API URL was changed, unlike other integrations. A malicious maintainer could change the API URL to a server they control and trigger a test, causing the API key to be sent to that server.

GitLab

Originally disclosed on GitLab

  • Fixed in 21 days
  • Disclosed after 21 days

HackerOne report #1724402 by ryotak on 2022-10-06, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

Due to the incomplete fixes for CVE-2022-2497 and CVE-2022-2882, a malicious maintainer can still leak the API key of Datadog by changing integration URL.

Description

In the patch for CVE-2022-2882, some fields of Github integration model was modified, and exposes_secrets: true was added to repository_url field.
This option enables resetting of secrets once the field is updated, which makes exfiltrating of access tokens impossible.

ee/app/models/integrations/github.rb line 22-26

Ruby
    field :repository_url,  
      title: -> { s_('GithubIntegration|Repository URL') },  
      required: true,  
      exposes_secrets: true,  
      placeholder: 'https://github.com/owner/repository'  

However, there are some models that are missing exposes_secrets option.
While most of these models are using their own method to reset the secrets (e.g. before_validation :reset_passwowrd), there is one exception: Datadog

app/models/integrations/jenkins.rb line 30-44

Ruby
    before_validation :reset_password  
    [...]  
    def reset_password  
      # don't reset the password if a new one is provided  
      if (jenkins_url_changed? || username.blank?) && !password_touched?  
        self.password = nil  
      end  
    end  

In Datadog model, there are no validations for exposing the secrets, which allows a malicious maintainer to leak API keys by changing integration URL.

app/models/integrations/datadog.rb line 25

Ruby
      validates :api_url, public_url: { allow_blank: true }  
Steps to reproduce

(These steps to reproduce assumes that you're using gitlab.com. If you're using a self-hosted instance, you may need to prepare a GitLab runner.)

  1. Prepare 2 GitLab accounts. (Called account A and account B below)
  2. Create a project with account A and upload to the repository.
  3. In Settings -> Integrations -> Datadog, enable a Datadog integration and enter a new API key. (This API key can be a random string)
  4. In Project information -> Members, invite account B with the Maintainer permission.
  5. Login to account B, and open a project created in step 2.
  6. In Settings -> Integrations -> Datadog, fill the API URL to a server that you can read the request log. (I'd recommend https://requestbin.com/ if you need a server.)
  7. Click Test settings.
  8. Confirm the API key of Datadog is sent to the server.

If you have any troubles with these steps to reproduce, please check the video attached to this report.

Examples

Example repository that demonstrated the vulnerability: https://gitlab.com/Ry0taK/maintainer-integration-leak
As this repository is private, please let me know if you need to access this repository.

What is the current bug behavior?

Access tokens for Datadog integration are keep remaining even after changing the API URLs.

What is the expected correct behavior?

Access tokens for Datadog integration should be cleared once API URLs are changed.

Suggested fix

Add exposes_secrets: true to api_url of Datadog integration model.

Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
System information  
System:         Ubuntu 20.04  
Proxy:          no  
Current User:   git  
Using RVM:      no  
Ruby Version:   2.7.5p203  
Gem Version:    3.1.6  
Bundler Version:2.3.15  
Rake Version:   13.0.6  
Redis Version:  6.2.7  
Sidekiq Version:6.4.2  
Go Version:     unknown

GitLab information  
Version:        15.4.1-ee  
Revision:       7b2ed8f038f  
Directory:      /opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:     PostgreSQL  
DB Version:     13.6  
URL:            https://gl.ryotak.me  
HTTP Clone URL: https://gl.ryotak.me/some-group/some-project.git  
SSH Clone URL:  [email protected]:some-group/some-project.git  
Elasticsearch:  no  
Geo:            no  
Using LDAP:     no  
Using Omniauth: yes  
Omniauth Providers:

GitLab Shell  
Version:        14.10.0  
Repository storage paths:  
- default:      /var/opt/gitlab/git-data/repositories  
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell  
Impact

A malicious maintainer can leak Datadog API key, and modify/exfiltrate information on Datadog.

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

The Datadog integration model lacked the `exposes_secrets` option on its `api_url` field, so changing the URL did not reset the stored API key.

Impact

A malicious maintainer could leak the Datadog API key and use it to modify or exfiltrate information on Datadog.

What the attacker needed

Two GitLab accounts; maintainer access to a project; Datadog integration enabled with an API key; a server to receive requests

The fix

The Datadog integration model should be updated to include `exposes_secrets: true` on the `api_url` field so that the API key is cleared when the URL changes.

How it was found

  1. Create two GitLab accounts, A and B.
  2. With account A, create a project and upload a CI configuration file.
  3. Enable the Datadog integration and enter a new API key.
  4. Invite account B as a Maintainer.
  5. Log in as account B, go to the Datadog integration settings, and change the API URL to a server you control.
  6. Click 'Test settings' and observe the API key being sent to your 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.

In GitLab, a project can be connected to Datadog, a monitoring service, using an API key. Normally, if someone changes the address of the Datadog server, the saved key should be erased to prevent it from being sent to the wrong place. Here, the key was not erased, so a user with maintainer rights could redirect it to their own server and steal it.

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.