Skip to content
OAuth / SSO Disclosed report Intermediate

Gitlab Grafana Admin Privilege Escalation

Grafana's GitLab OAuth login identifies users by their GitLab username rather than a stable identifier. A low-privileged GitLab user could change their username to match a Grafana admin's username and then log in to Grafana as that admin.

GitLab

Originally disclosed on GitLab

  • Fixed in 5 months
  • Disclosed after 5 months

HackerOne report #1601147 by bugdiscloseguys on 2022-06-15, assigned to @rshambhuni:

Report | Attachments | How To Reproduce

Report

Summary

Gitlab's Grafana Sigin in with Gitlab allows a lower priviliged / or a non priviliged user when signup is enabled to takeover Grafana's accounts including admin. This is because Grafana uses Gitlab's username to authenticate - https://github.com/grafana/grafana/blob/1af63ba5f97625c85b3d191a9394805bcd0739ff/pkg/login/social/gitlab_oauth.go#L131

Steps to reproduce
  • Setup a Gitlab instance with Grafana admin access (username/password)

https://docs.gitlab.com/omnibus/settings/grafana.html#enable-login-using-username-and-password

  • Login at gitlab-instance/-/grafana
  • Add a new Grafana admin user named someuser with any random email lets say [email protected] from Grafana admin.
  • Now go to Gitlab and either allow sign up or create a low priviliged (regular) user with username johnsmith and any email [email protected]
  • In a different session, Login as the newly created Gitlab user (someuser) in Gitlab.
  • Change your username to johnsmith (Grafana admin)
  • Now open gitlab-instance/-/grafana and click Signin with Gitlab
  • After succssful OAuth flow, notice that you're signed into Grafana admin account that we setup earlier which has completely different email but as Grafana uses username in OAuth flow to find account & initiate session it causes an auth bypass / priv. escalation.

I've attached a video PoC/Steps for the same.

Note - There might be a few other scenarios to exploit this misconfig.

Impact

Privilige escalation or Authentication bypass on Grafana If signup is enabled.

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

Impact

A low-privileged or non-privileged user could escalate privileges to Grafana admin or bypass authentication if signup is enabled.

What the attacker needed

GitLab instance with Grafana integration; Signup enabled or ability to create users; Attacker has a GitLab account

How it was found

  1. Set up a GitLab instance with Grafana admin access.
  2. Log in to Grafana and create a new Grafana admin user with a chosen username.
  3. Create a low-privileged GitLab user with a different username.
  4. Log in as that GitLab user and change their username to match the Grafana admin's username.
  5. Open the Grafana sign-in page and click 'Sign in with GitLab'.
  6. After the OAuth flow, you are signed in to the Grafana admin account.

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.

When you log in to a website using another service (like GitLab), the website usually trusts that service to tell it who you are. Here, Grafana trusted the username from GitLab, but usernames can be changed by users. So someone could rename themselves to match an admin's username and trick Grafana into giving them the admin's account.

What is OAuth / SSO?

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.