CVE-2022-4342 Bypassed - Maintainer can leak masked webhook secrets by changing target URL of the webhook
A maintainer could leak masked webhook secrets by changing the webhook target URL to an attacker-controlled server and masking that URL, causing the secret to be sent in the request. This bypasses the fix for CVE-2022-4342.
GitLab
Originally disclosed on GitLab
- Fixed in 22 hours
- Disclosed after 22 hours
⚠️ 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 #1915507 by theluci on 2023-03-23, assigned to @ottilia_westerlund:
Report | Attachments | How To Reproduce
Report
Hello, I found that CVE-2022-4342 which was fixed in version 15.7.2 can be bypassed. And a malicious maintainer can leak masked webhook secrets by changing target URL of the webhook.
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 masking the attacker controlled server url itself. (see Steps/POC)
POC
Steps to reproduce on Gitlab.com
victim is the owner of a project project-victim
attacker is a maintainer in project-victim
victimgoes to hisproject-victimwebhook settings,https://gitlab.com/GROUP/PROJECT/-/hooksvictimconfigures a webhook with a secret token and mask the secret token. For example, Put the URL like thishttps://example.com?token=secret-token- Click to add a mask, add the value
secret-tokenwith the replacementtoken. Click save for the webhook

-
attackergoes toproject-victimwebhook settings,https://gitlab.com/GROUP/PROJECT/-/hooks -
Scroll to the bottom of the page to the list of configured hooks and edit the webhook.
-
attackeredit the url to an "attacker controlled server" (i used https://webhook.site to catch the request). Keep the token={token} part. Like this `https://WEBHOOK.SITE?token={TOKEN} and mask the URL of the attacker controlled server as shown in the image

- click save
- click test
- check your server to see that the request is sent to the new URL and containing the secret token

- attacker can remove the trace by changing the url back to the original url
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:
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 masking feature did not properly prevent a user from masking the attacker-controlled URL, allowing the secret to be revealed when the webhook was triggered.
Impact
Maintainers can leak secret masked values that should not be accessible after configuration.
What the attacker needed
Attacker is a maintainer in the project; victim has configured a webhook with a masked secret
How it was found
- Victim configures a webhook with a secret token and masks the secret token.
- Attacker edits the webhook URL to an attacker-controlled server, keeping the token part and masking the new URL.
- Attacker saves and tests the webhook.
- Attacker checks their server to see the request containing the secret token.
- Attacker changes the URL back to the original to remove the trace.
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 to another server when something happens. GitLab lets you hide secret parts of the webhook URL, but a user with maintainer rights could change the URL to their own server and trick GitLab into sending the secret there.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.