Skip to content
OAuth / SSO Disclosed report Intermediate

Ability to bypass email verification for OAuth grants results in accounts takeovers on 3rd parties

GitLab's OAuth authorisation endpoint did not enforce email verification, allowing an attacker to complete an OAuth grant with an unverified email. This could lead to account takeover on third-party sites that trust the email as an identifier.

cache-money Follow

Originally disclosed on HackerOne

Bounty$3,000 High View original
  • Triaged in 2 hours
  • Fixed in 24 days
  • Paid in 2 hours
  • Disclosed after 3 months

Summary

There's a limitation that requires a validated email before going through the OAuth flow, however this is bypassable. Bypassing this means the target site assumes your email is validated, and actually ends up signing you in with an non-validated email. This behavior can frequently lead to account takeovers in 3rd parties since they often use the email as an identifier, and fold all OAuth/manually created accounts into one. In my example I am going to demonstrate an account takeover on https://laravelshift.com/, however this concept is widely exploitable.

It should also be possible to use this technique to get into internal company using pages that just look for @domain.com in the email before allowing them access.

Steps to reproduce

  1. Create a Bitbucket or GitHub account with a random email, and login to https://laravelshift.com/. (We're seeding a victim account).
  2. In a different browser, create a new GitLab account with that same email but never confirm it.
  3. In that browser, visit LaravelShift and click "Sign in with GitLab", notice you land on a page that states you cannot complete the OAuth grant without validating your email.

Run the following request in Burp replacing your cookies, CSRF token, and state parameter.

POST /oauth/authorize HTTP/1.1
Host: gitlab.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 354
DNT: 1
Connection: close
Cookie: [COOKIES]

utf8=%E2%9C%93&authenticity_token=[CSRF TOKEN]&client_id=6dd35c52b02a99eca3454505c4b1f1fa761ad1125bcdccdbc1c290877ef25093&redirect_uri=https%3A%2F%2Flaravelshift.com%2Fauth%2Fgitlab%2Fcallback&state=[STATE VALUE FROM URL]&response_type=code&scope=&nonce=
  1. Notice the request succeeds with a 302 to LaravelShift with the code.
  2. Visit that URL and notice you get logged into the victim's account from step 1. This works since the GitLab email is assumed to be trusted and validated.

Impact

Account takeovers on 3rd parties due to developers assuming GitLab is properly checking validated emails.

What is the current bug behavior?

It's possible to play the /oauth/authorize request directly to bypass the Verify the email address in your account profile before you sign in. prompt.

What is the expected correct behavior?

The email verification check should be enforced at this step of the process as well.

Impact

Thanks, -- Tanner

The original report as published on HackerOne, by cache-money. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

GitLab offers an OAuth provider that third-party applications use to sign users in. The flow uses the authorisation code grant: the third party redirects the user to GitLab, and on approval GitLab redirects back with a code.

GitLab places a restriction on this flow: an account must have a validated email address before it can complete an OAuth grant. When an unvalidated account tries, GitLab shows a page stating that the email address in the account profile must be verified before signing in. The researcher found that this check can be bypassed by sending the authorisation request directly, and that third parties which treat the GitLab email as trusted then sign the user in with an email that was never validated.

The report demonstrates the issue against https://laravelshift.com/, but the researcher notes the concept is widely exploitable.

Setup

The demonstration needs two accounts sharing one email address, plus a third-party application that supports GitLab sign-in.

  1. A Bitbucket or GitHub account registered with a random email address, used to sign in to https://laravelshift.com/. This seeds the victim account on the third party.
  2. A GitLab account created with the same email address, which is never confirmed.
  3. A browser separate from the one used in step 1, so the two sessions do not interfere.
  4. Burp (or a comparable proxy) to replay the authorisation request, with the attacker's cookies, CSRF token and state parameter substituted.

The precondition is that the third party folds OAuth logins and manually created accounts together using the email address as the identifier, which the researcher says is common.

Finding it

GitLab displays a page stating the OAuth grant cannot be completed without validating the email address. That check is enforced in the interactive flow, but the underlying /oauth/authorize endpoint accepts a direct POST. Sending that request by hand skips the prompt and returns the authorisation code anyway.

What makes this matter is the trust model on the other side. Third parties assume GitLab has verified the email before issuing the grant, so they use the email as the account identifier. An unvalidated email that reaches them through OAuth is therefore treated as if it had been proven.

Exploitation

Step 1: seed the victim account

Create a Bitbucket or GitHub account with a random email address and log in to https://laravelshift.com/ with it. This creates the account on the third party that the attacker will later take over.

Step 2: create the unvalidated GitLab account

In a different browser, create a new GitLab account using the same email address, and never confirm it.

Step 3: observe the block in the normal flow

In that browser, visit LaravelShift and click "Sign in with GitLab". The result is a page stating that the OAuth grant cannot be completed without validating the email address.

Step 4: replay the authorisation request directly

Send the following request in Burp, replacing the cookies, CSRF token and state parameter with the attacker's own values:

HTTP
POST /oauth/authorize HTTP/1.1
Host: gitlab.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 354
DNT: 1
Connection: close
Cookie: [COOKIES]

utf8=%E2%9C%93&authenticity_token=[CSRF TOKEN]&client_id=[redacted]&redirect_uri=https%3A%2F%2Flaravelshift.com%2Fauth%2Fgitlab%2Fcallback&state=[STATE VALUE FROM URL]&response_type=code&scope=&nonce=

The body carries the parameters the authorisation endpoint expects: client_id identifies the third-party application, redirect_uri is the callback on laravelshift.com, response_type=code requests an authorisation code, state ties the request to the attacker's session, and authenticity_token is the CSRF token. The Cookie header holds the attacker's GitLab session.

Step 5: use the returned code

The request succeeds with a 302 redirect to LaravelShift carrying the code. Visiting that URL logs the attacker into the victim's account from step 1. The third party accepts the login because it assumes the GitLab email has been validated.

Root cause

The email verification check exists in the interactive OAuth consent path but is not enforced when /oauth/authorize is called directly. The researcher describes this as playing the request directly to bypass the prompt. The request includes the attacker's CSRF token and state value.

The downstream failure belongs to the third party: it treats the email in the OAuth response as verified and merges OAuth and manually created accounts on that basis. GitLab's guarantee that a grant implies a validated email is what those applications rely on, and the bypass breaks that guarantee.

Impact

An attacker who controls an email address that is already registered on a third-party application can create an unvalidated GitLab account with the same address, complete the OAuth grant through the direct request, and be signed in to the existing account on the third party. The report describes this as account takeovers on third parties, caused by developers assuming GitLab properly checks validated emails.

The researcher also notes it should be possible to use the technique to reach internal company pages that only check for @domain.com in the email before granting access. That use is stated as a possibility, not demonstrated.

The impact depends on the third party using the email as the account identifier and folding OAuth and manual accounts together, which the researcher says happens frequently.

Fix

The expected correct behaviour, as stated in the report, is that the email verification check should be enforced at this step of the process as well, meaning the direct /oauth/authorize request must be subject to the same validation as the interactive flow. The report does not describe a specific patch.

Variants to test

  • Other OAuth providers with an email verification gate. Try submitting the authorisation endpoint directly, with a valid session, CSRF token and state, for an account whose email is unconfirmed. A positive result is a 302 to the client's redirect_uri containing a code instead of the verification prompt.
  • Third parties that merge accounts by email. Register on the target with one identity, then attempt an OAuth login from a provider account holding the same unverified email. A positive result is being signed in to the pre-existing account.
  • Domain-based access checks. On internal or partner pages that grant access based on an @domain.com email, attempt the same direct authorisation request with an unverified address in that domain. A positive result is access to the restricted page.

Hunting notes

This class of bug sits at the boundary between an identity provider and the applications that trust it. The signal during recon is an OAuth provider that advertises an email verification requirement, combined with client applications that use the email address as the account key. The researcher demonstrated the bypass leading to a login into the victim's account on laravelshift.com. The report was disclosed on 1 October 2020, rated high severity, with a 3,000 USD bounty.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

GitLab is a website where people store and share code. Besides being a place to host code, GitLab can act as a "login service" for other websites: instead of creating a username and password on every site, you can click "Sign in with GitLab" and GitLab tells the other site who you are. This is called OAuth, and the other site is called a third party.

GitLab has a rule for this: before it will vouch for you to another site, the email address on your GitLab account must be confirmed. Confirming means GitLab sends you a message at that address and you click a link in it, which proves the address really belongs to you. If your email is not confirmed, GitLab shows a page saying you must verify the email address in your account profile before you sign in.

The researcher found that this rule can be skipped. The page with the warning is only one way to ask GitLab for permission. The underlying request that does the real work can also be sent by hand, and when it is sent that way GitLab hands out the permission without checking whether the email was confirmed.

Why does that matter? Because third-party sites trust GitLab. They assume that if GitLab let you in, your email must be real and confirmed. Many of them use the email address as the identity of the account: if you log in with GitLab using an email that already exists on their site, they treat you as the owner of that existing account. So an attacker who can get GitLab to vouch for an unconfirmed email can walk into somebody else's account on the third-party site.

The researcher demonstrated this on https://laravelshift.com/, a real site, and noted that the same idea works widely. The report was rated high severity and paid a 3,000 USD bounty.

The pieces involved

Before the steps make sense, here are the parts of the picture.

  • OAuth: a way for one website to ask another website to confirm who you are, without sharing your password. Everyday comparison: a club asks a trusted friend to vouch for you at the door. The friend (GitLab) says "this person is who they claim", and the club (the third party) lets you in.
  • OAuth provider: the site that does the vouching. Here, GitLab.
  • Third party / client application: the site that relies on the voucher. Here, laravelshift.com.
  • Authorisation code grant: the specific OAuth recipe used here. The third party sends you to GitLab, GitLab asks you to approve, and on approval GitLab sends you back to the third party with a short-lived code. The third party receives the code and uses it to complete the login. Think of the code as a claim ticket: the club gives you a ticket at the door, and the club's back office exchanges the ticket for your details.
  • Email validation: proof that an email address belongs to you, normally by clicking a link sent to it.
  • Cookie: a small piece of data your browser stores for a website and sends back with every request. It is how a site remembers that you are logged in. If someone else has your cookie, they can act as you on that site.
  • CSRF token: a secret value embedded in a form or request that the site issued to your browser. It proves the request came from a page the site itself served, not from a malicious page trying to make your browser do something. The attacker supplies their own CSRF token in the request.
  • state parameter: a random value the third party generates and expects to see again when GitLab redirects back. It ties the returning login to the session that started it, so a login started in one place cannot be quietly finished in another.
  • Burp: a tool that sits between your browser and a website and lets you look at and edit the requests before they are sent. It is like an interception desk for letters: you can read a letter, change a word, and send it on.
  • POST request: one of the ways a browser talks to a server. A POST carries data in its body, typically used when you submit a form.
  • 302 redirect: a server answer that says "go look over there instead", pointing the browser at another address.
  • Endpoint: a specific address on a server that does a specific job, such as /oauth/authorize.
  • Account takeover: getting into someone else's account and acting as them.

Setting up the demonstration

The demonstration needs two accounts that share one email address, plus a third-party site that supports GitLab sign-in.

  1. A Bitbucket or GitHub account registered with a random email address, used to sign in to https://laravelshift.com/. This creates the account on the third party that will later be taken over. The researcher calls this "seeding a victim account": planting the account first so there is something to break into later.
  2. A GitLab account created with the same email address, which is never confirmed. This is the account whose email GitLab has not proven.
  3. A browser separate from the one used in step 1, so the two logins do not interfere with each other. Two sessions in one browser would overwrite each other's cookies.
  4. Burp, or a similar proxy, to replay the authorisation request with the attacker's own cookies, CSRF token and state parameter filled in.

The precondition is that the third party merges OAuth logins and manually created accounts using the email address as the identifier. The researcher says this is common: the site keeps one account per email, no matter how you logged in.

Finding it

The researcher started from the restriction itself. GitLab refuses to complete an OAuth grant for an account whose email is not validated, and shows a page saying the email address in the account profile must be verified before signing in.

That check lives in the interactive flow, the path a normal person takes by clicking buttons. But the endpoint behind it, /oauth/authorize, also accepts a direct POST. Sending that request by hand skips the warning page and returns the authorisation code anyway. The comparison: a building has a receptionist who checks your badge, but the side door opens with the same key and has no receptionist.

What makes this matter is the trust on the other side. Third parties assume GitLab has verified the email before issuing the grant, so they use the email as the account identifier. An unvalidated email that reaches them through OAuth is therefore treated as if it had been proven.

Exploitation

Step 1: seed the victim account

Create a Bitbucket or GitHub account with a random email address and log in to https://laravelshift.com/ with it. This creates the account on the third party that the attacker will later take over. The point of this step is to have a real, existing account on the target site, keyed to an email address the attacker knows.

Step 2: create the unvalidated GitLab account

In a different browser, create a new GitLab account using the same email address, and never confirm it. The point is to hold a GitLab identity that claims the same email but has never proven it.

Step 3: observe the block in the normal flow

In that browser, visit LaravelShift and click "Sign in with GitLab". The result is a page stating that the OAuth grant cannot be completed without validating the email address. This step confirms the restriction exists and shows exactly where the normal path stops.

Step 4: replay the authorisation request directly

Send the following request in Burp, replacing the cookies, CSRF token and state parameter with the attacker's own values:

HTTP
POST /oauth/authorize HTTP/1.1
Host: gitlab.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 354
DNT: 1
Connection: close
Cookie: [COOKIES]

utf8=%E2%9C%93&authenticity_token=[CSRF TOKEN]&client_id=[redacted]&redirect_uri=https%3A%2F%2Flaravelshift.com%2Fauth%2Fgitlab%2Fcallback&state=[STATE VALUE FROM URL]&response_type=code&scope=&nonce=

Line by line:

  • POST /oauth/authorize HTTP/1.1: this is a POST request to the authorisation endpoint on GitLab. It is the same job the warning page would have done, sent by hand instead of through the page.
  • Host: gitlab.com: the site the request is addressed to.
  • Content-Type: application/x-www-form-urlencoded: says the body is formatted like a normal web form, as name=value pairs joined by &.
  • Content-Length: 354: the size of the body in bytes, so the server knows where it ends.
  • DNT: 1: a standard browser header asking sites not to track the user. It is incidental to the attack.
  • Connection: close: tells the server to close the connection after answering.
  • Cookie: [COOKIES]: the attacker's GitLab session cookies, which is what makes GitLab treat the request as coming from the attacker's logged-in account. The placeholder stands for the real values.
  • The blank line separates the headers from the body.
  • utf8=%E2%9C%93: a form field that marks the character encoding, here the check mark character encoded for UTF-8. It is part of the form GitLab's page normally submits.
  • authenticity_token=[CSRF TOKEN]: the CSRF token, proving the request belongs to the attacker's own session. The attacker supplies their own token, so this does not block the replay.
  • client_id=[redacted]: identifies which third-party application is asking. This is LaravelShift's public identifier on GitLab.
  • redirect_uri=https%3A%2F%2Flaravelshift.com%2Fauth%2Fgitlab%2Fcallback: where GitLab should send the user afterwards, URL-encoded. Decoded, it is https://laravelshift.com/auth/gitlab/callback, the address on LaravelShift that receives the login result.
  • state=[STATE VALUE FROM URL]: the value that ties this request to the login the attacker started, taken from the URL. The attacker uses their own value, so it does not prevent the replay either.
  • response_type=code: asks GitLab for an authorisation code rather than another kind of answer.
  • scope=: the permissions being requested, left empty here.
  • nonce=: an extra value some flows use to prevent replay; here it is empty.

The body carries the parameters the authorisation endpoint expects. The Cookie header holds the attacker's GitLab session. The request includes the attacker's CSRF token and state value.

Step 5: use the returned code

The request succeeds with a 302 redirect to LaravelShift carrying the code. Visiting that URL logs the attacker into the victim's account from step 1. The third party accepts the login because it assumes the GitLab email has been validated. In the claim-ticket comparison: the club's back office takes the ticket, looks up the email on it, finds an existing member with that email, and hands over that member's account.

Root cause

The email verification check exists in the interactive OAuth consent path but is not enforced when /oauth/authorize is called directly. The researcher describes this as playing the request directly to bypass the prompt.

The downstream failure belongs to the third party: it treats the email in the OAuth response as verified and merges OAuth and manually created accounts on that basis. GitLab's guarantee that a grant implies a validated email is what those applications rely on, and the bypass breaks that guarantee.

Impact

An attacker who controls an email address that is already registered on a third-party application can create an unvalidated GitLab account with the same address, complete the OAuth grant through the direct request, and be signed in to the existing account on the third party. The report describes this as account takeovers on third parties, caused by developers assuming GitLab properly checks validated emails.

The researcher also notes it should be possible to use the technique to reach internal company pages that only check for @domain.com in the email before granting access. That use is stated as a possibility, not demonstrated.

The impact depends on the third party using the email as the account identifier and folding OAuth and manual accounts together, which the researcher says happens frequently.

Fix

The expected correct behaviour, as stated in the report, is that the email verification check should be enforced at this step of the process as well, meaning the direct /oauth/authorize request must be subject to the same validation as the interactive flow. The report does not describe a specific patch.

Variants to test

  • Other OAuth providers with an email verification gate. Try submitting the authorisation endpoint directly, with a valid session, CSRF token and state, for an account whose email is unconfirmed. A positive result is a 302 to the client's redirect_uri containing a code instead of the verification prompt.
  • Third parties that merge accounts by email. Register on the target with one identity, then attempt an OAuth login from a provider account holding the same unverified email. A positive result is being signed in to the pre-existing account.
  • Domain-based access checks. On internal or partner pages that grant access based on an @domain.com email, attempt the same direct authorisation request with an unverified address in that domain. A positive result is access to the restricted page.

Hunting notes

This class of bug sits at the boundary between an identity provider and the applications that trust it. The signal during recon is an OAuth provider that advertises an email verification requirement, combined with client applications that use the email address as the account key. The researcher demonstrated the bypass leading to a login into the victim's account on laravelshift.com. The report was disclosed on 1 October 2020, rated high severity, with a 3,000 USD bounty.

Glossary

  • OAuth: a system where one website vouches for your identity to another website, so you do not have to create a password everywhere.
  • OAuth provider: the website that does the vouching, here GitLab.
  • Third party / client application: the website that relies on the voucher to sign you in, here laravelshift.com.
  • Authorisation code grant: the OAuth recipe where the provider sends the client a short-lived code, which the client exchanges for a token and your details.
  • Authorisation code: the short-lived value GitLab hands back to the third party after approval, used to fetch your details.
  • Endpoint: a specific address on a server that performs a specific job, such as /oauth/authorize.
  • POST request: a request that carries data in its body, typically used when submitting a form.
  • 302 redirect: a server answer telling the browser to go to a different address.
  • Cookie: a small value your browser stores for a site and sends back with each request, used to keep you logged in.
  • Session: the logged-in state a site keeps for you, identified by your cookie.
  • CSRF token: a secret value issued to your session and included in requests, proving the request came from the site's own pages.
  • state parameter: a random value the third party generates and checks on return, tying the login to the session that started it.
  • client_id: the public identifier of a third-party application registered with the OAuth provider.
  • redirect_uri: the address on the third party where the provider sends the user after approval.
  • response_type: the parameter saying what kind of answer the client wants, here a code.
  • scope: the set of permissions the client is asking for.
  • nonce: an extra value some login flows use to prevent a request being reused.
  • URL encoding: writing characters in a form safe for URLs, such as %3A for a colon.
  • Burp: a tool that intercepts and lets you edit requests between your browser and a website.
  • Email validation: proving an email address belongs to you, usually by clicking a link sent to it.
  • Account takeover: gaining access to someone else's account and acting as them.
  • Recon: the early stage of security testing where you look around a target to see what it offers and how it behaves.
  • Severity: a rating of how serious a bug is, here high.
  • Bounty: a payment a company makes to a researcher who reports a valid security bug.

More by cache-money

View all

3 more disclosed reports, best first.

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.