Skip to content
Info disclosure Disclosed report Intermediate

Maintainer can leak masked webhook secrets by adding a new parameter to the webhook URL to bypass the newly added validation logic

A maintainer could leak masked webhook secrets by editing the webhook URL to include a new variable, which bypassed a validation check that was supposed to reset URL variables when the URL changed. The attacker could then send a test request to a server they control and see the secret in plain text.

GitLab

Originally disclosed on GitLab

  • Fixed in 44 days
  • Disclosed after 44 days

⚠️ 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 #1871136 by 0xn3va on 2023-02-12, assigned to @rshambhuni:

Report | Attachments | How To Reproduce

Report

Summary

There is a vulnerability https://gitlab.com/gitlab-org/gitlab/-/issues/385118 that was fixed and disclosed recently. The fix adds an extra check in case the URL changes:

Ruby
###  https://gitlab.com/gitlab-org/gitlab/-/commit/7f34991ae36f1804610ba9980e31191394c8b208

###  ...

  before_validation :reset_url_variables, unless: ->(hook) { hook.is_a?(ServiceHook) }  
 
###  ...

  def reset_url_variables  
    self.url_variables = {} if url_changed? && !encrypted_url_variables_changed?  
  end

However, reset_url_variables will return false if the URL variables have also been changed. This allows bypassing the check by adding a new variable to the modified URL.

Steps to reproduce

As a project owner

  1. Create a project
  2. Add another user to the project as a maintainer
  3. Go to Settings > Webhooks
  4. Put the URL https://example.com?token=secret-token
  5. Click to add a mask
  6. Add the value secret-token with the replacement TOKEN
  7. Click save for the webhook

As a maintaner

  1. Open the project
  2. Go to Settings > Webhooks
  3. Click edit on the webhook
  4. Edit the URL to your controlled server like that: https://<ATTACKER_SERVER>?token={TOKEN}&a=aaaaa
  5. Add the value aaaaa with the replacement A
  6. Save the webhook
  7. Now click Test to send a request
  8. Check your server logs; it will contain the secret in plain text
Impact

This vulnerability allows an attacker with the Maintainer role to leak webhook secrets.

What is the current bug behavior?

Adding or deleting a new secret does not reset the previously saved ones

What is the expected correct behavior?

Adding or deleting a new secret resets the previously saved ones

Relevant logs and/or screenshots
Screen_Recording_2023-02-12_at_12.55.50.mov From the original on GitLab
Output of checks

This bug happens on GitLab.com

Impact

This vulnerability allows an attacker with the Maintainer role to leak webhook secrets.

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 validation method `reset_url_variables` returns false when URL variables are also changed, so the check that should clear variables on URL change is bypassed.

What the attacker needed

Maintainer role on a project; Webhook with masked secret configured

How it was found

  1. As project owner, create a project and add another user as maintainer.
  2. Go to Settings > Webhooks and add a webhook with URL containing a secret token.
  3. Add a mask for the secret token value.
  4. Save the webhook.
  5. As maintainer, edit the webhook URL to point to an attacker-controlled server and add a new variable.
  6. Add a mask for the new variable value and save.

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.

Webhooks are automatic messages sent from one system to another. A secret token can be included in the webhook URL to authenticate. The system tried to hide these secrets by masking them, but a flaw allowed a user with maintainer rights to change the URL in a way that revealed the secret.

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.