Skip to content
Info disclosure Disclosed report Intermediate

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.

  1. Log in to github.com (note: GITHUB)
  2. Create a repository, name it anything
  3. Create an API token with "repo" scope, https://github.com/settings/tokens

Then on GITLAB:

  1. Create two users victim and attacker
  2. Log in as victim, and create a new project. Make sure to UNCHECK "initialize with README"
  3. Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/project_members
  4. Invite attacker as a maintainer to the project
  5. Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/repository and expand "Mirroring repositories""
  6. 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)
  7. Now go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/integrations/github/edit
  8. fill in the access token HIDDEN_TOKEN and GitHub repo https://github.com/anything/anything
  9. Click save, the token field should turn empty
  10. Log in with attacker
  11. Go to https://gitlab.com/GROUPNAME/PROJECTNAME/-/settings/integrations/github/edit
  12. Enter a new value for server URL using the catch server
  13. Click Test settings
  14. 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

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

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

  1. Create a GitHub repository and generate a personal access token with repo scope.
  2. On GitLab, create a project as the victim and invite the attacker as a maintainer.
  3. Configure repository mirroring with the GitHub token.
  4. Set up the GitHub integration with the token.
  5. As the attacker, change the integration's server URL to a catch server and click 'Test settings'.
  6. 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.

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.