Maintainer can leak Github access tokens by changing integration URL (even after 15.2.1 patch)
A maintainer could change the GitHub integration URL to a server they control, and the previously configured access token would be sent to that server when testing the integration. This allowed the maintainer to steal the token and access the victim's GitHub repositories.
GitLab
Originally disclosed on GitLab
- Fixed in 43 days
- Disclosed after 43 days
HackerOne report #1656722 by joaxcar on 2022-08-01, assigned to GitLab Team:
Report | How To Reproduce
Report
Summary
In the 15.2.1 patch there was a fix for my reports that are bundled in the report https://hackerone.com/reports/1557992
The patch failed to fix at least one integration, the Github one. This integration still allows for changing the URL and leaking the configured access token.
This makes it possible for a malicious user(maintainer) to change the server to a user controlled server, where the attacker can then extract the token. The attacker needs maintainer access to the project, but should nevertheless not have access to the configured access token. The impact is the same as for my previous reports. I did mention this issue in the original report but I guess it slipped through.
Steps to reproduce
Make sure to have a webhook server where you can see incoming requests. I use https://webhook.site for my tests
You will need to generate a project with mirrored repository from Github for the integration to be enabled. So I will first describe that.
- Log in to github.com (note: GITHUB)
- Create a repository, name it anything
- Create an API token with "repo" scope, https://github.com/settings/tokens
Then on GITLAB:
- Create two users
victimandattacker - Log in as
victim, and create a new project. Make sure to UNCHECK "initialize with README" - Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/project_members
- Invite
attackeras a maintainer to the project - Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/repository and expand "Mirroring repositories""
- Configure both a PUSH and a PULL mirroring, enter URL as https://[email protected]/REPOPATH and the generated API token as password. Make sure to check all boxes (I dont know what is needed, check everything)
- Now go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/integrations/github/edit
- fill in the access token
HIDDEN_TOKENand GitHub repo https://github.com/anything/anything - Click save, the token field should turn empty
- Log in with
attacker - Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/integrations/github/edit
- Enter a new value for server URL using the catch server
- Click
Test settings - Go to the catch server and see that a request have been received with the token in plain text
If the "Test settings" button is missing, there is something wrong with the repo mirroring.
Impact
User with maintainer access can leak the configured GitHub access token. This token is supposed to be hidden and will give the attacker access to the GitHub API as the victim user.
What is the current bug behavior?
Changing server URL does not reset the previous access token
What is the expected correct behavior?
When the server URL changes, the token should be deleted
Output of checks
This bug happens on GitLab.com
Impact
Leakage of sensitive tokens to other maintainers. Potentially giving the attacker access to external systems
Impact
Leakage of sensitive tokens to other maintainers. Potentially giving the attacker access to external systems
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
Impact
A maintainer could leak the configured GitHub access token, gaining access to the GitHub API as the victim user.
What the attacker needed
Maintainer access to a GitLab project; GitHub integration configured with a token; attacker controls a server to receive requests
The fix
The server URL change should delete the stored token.
How it was found
- Create a GitHub repository and generate a personal access token with repo scope.
- On GitLab, create a project as the victim and invite the attacker as a maintainer.
- Configure repository mirroring with the GitHub token.
- Set up the GitHub integration with the token.
- As the attacker, change the integration's server URL to a catch server and click 'Test settings'.
- Observe the token sent in plain text to the catch 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.
A project maintainer is someone who can change settings. The GitHub integration lets a project connect to GitHub using a secret token. The bug meant that if the maintainer changed the GitHub server address to their own server, the secret token was still sent there, so they could steal it.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.