Skip to content
Info disclosure Disclosed report Intermediate

Maintainer can leak masked webhook secrets by manipulating URL masking

A maintainer could leak masked webhook secrets by manipulating URL masking to bypass validation logic. The attacker could then send a test request to an attacker-controlled URL containing the secret token.

GitLab

Originally disclosed on GitLab

  • Fixed in 51 days
  • Disclosed after 51 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 #1976206 by theluci on 2023-05-07, assigned to @nmalcolm:

Report | Attachments | How To Reproduce

Report

Hello,
I recently submitted a report #1915507 which was closed as duplicate of https://gitlab.com/gitlab-org/gitlab/-/issues/391685.
The fix to https://gitlab.com/gitlab-org/gitlab/-/issues/391685 can be bypassed.

Summary

There is an option to mask parts of a webhook URL to treat it as a secret value.
https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#mask-sensitive-portions-of-webhook-urls

When this feature is used any secret string in the configured URL will be masked in the UI and in any logs in the UI. The values work the same as other tokens in that they are not even accessible by the user configuring it after it is first configured. It should not be possible for the initial user or any other users to retrieve these values.

The docs states this about the secret

Sensitive portions do not get logged and are encrypted at rest in the database.

However, there is a way to leak masked webhook secrets by bypassing the validation logic. (See Vulnerability)

Vulnerability

The fix changed validation logic as following,

  def reset_url_variables  
    interpolated_url_was = interpolated_url(decrypt_url_was, url_variables_were)

    return if url_variables_were.empty? || interpolated_url_was == interpolated_url

    self.url_variables = {} if url_changed? && url_variables_were.to_a.intersection(url_variables.to_a).any?  
  end  

To bypass the validation logic

  1. attacker mask the victim-url such as https://victim-url?token={TOKEN} becomes {masked-url}?token={TOKEN} and clicks save.

This will not reset url_variables as url_changed? returns false.

  1. attacker now changes the url such as {masked-url}?token={TOKEN} becomes https://attacker-url?token={TOKEN}
  2. attacker masks the attacker-url with the same mask {masked-url}. So, that url finally becomes {masked-url}?token={TOKEN} and clicks save.

This will not reset url_variables as interpolated_url_was == interpolated_url condition is satisfied.

  1. attacker can now click test to receive masked webhook secrets.

Steps to reproduce

victim is the owner of a project victim-project
attacker is a maintainer in victim-project

As victim,

  1. victim goes to his victim-project webhook settings, https://gitlab.com/<victim-group>/<victim-project>/-/hooks
  2. victim configures a webhook with a secret token and mask the secret token. For example, Put the URL like this https://example.com?token=secret-token
  3. Click to add a mask, add the value secret-token with the replacement TOKEN. Click save for the webhook
W1.png
W1.png From the original on GitLab

As attacker

  1. attacker goes to victim-project webhook settings, https://gitlab.com/<victim-group>/<victim-project>/-/hooks
  2. Scroll to the bottom of the page to the list of configured hooks and edit the webhook.
  3. attacker mask the victim-url as {masked-url}. Keep the token={TOKEN} part. Like this, {masked-url}?token={TOKEN} and clicks save
W2.png
W2.png From the original on GitLab
  1. attacker add the attacker-url (i used https://webhook.site to catch the request). Keep the token={TOKEN} part. Like this, https://attacker-url?token={TOKEN} and mask the attacker-url using the same mask, {masked-url} as shown below
W3.png
W3.png From the original on GitLab
  1. attacker click save
  2. attacker click test
  3. Request is sent to the attacker-url and containing the secret token.
W4.png
W4.png From the original on GitLab

POC

poc-webhook-2.mp4 From the original on GitLab

Impact

Maintainers can leak secret masked values that should not be accessible after configuration.

Output of checks

This bug happens on GitLab.com (Probably on instance too)

Impact

Maintainers can leak secret masked values that should not be accessible after configuration.

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 validation logic that resets URL variables when the URL changes can be bypassed by masking the new URL with the same mask as the old URL, so the interpolated URLs appear equal and the variables are not reset.

What the attacker needed

Attacker is a maintainer in the project; victim has configured a webhook with a masked secret

How it was found

  1. As victim, configure a webhook with a secret token and mask the secret token.
  2. As attacker, edit the webhook and mask the victim URL as {masked-url}, keeping the [redacted] part, then save.
  3. Add the attacker URL with the same [redacted] part and mask the attacker URL using the same mask {masked-url}, then save.
  4. Click test to send a request to the attacker URL containing the secret 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.

Webhooks are automatic messages sent from a website to another URL when something happens. GitLab lets you hide parts of the webhook URL as secrets, but a bug allowed a project maintainer to trick the system into revealing those hidden secrets by changing the URL and its mask in a specific order.

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.