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

GitLab's OAuth authorize endpoint skipped the email-verification gate when POSTed directly, letting an unverified email grant OAuth codes and take over third-party accounts keyed on email.

- Payout: $3,000
- Severity: high
- Program: GitLab
- Found by: cache-money
- Disclosed: 2020-10-01
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/922456
- Library page: https://bugbountylibrary.com/r/h1%3A922456
- Tags: area:web domain:web impact:ato impact:internal-access kind:bounty platform:hackerone sev:high tech:oauth technique:recon vuln:account-takeover vuln:auth-bypass

**Target:** GitLab OAuth /oauth/authorize endpoint
**Root cause:** The email-verification check was enforced only in the UI flow, not on the POST /oauth/authorize handler, so a direct request issued an authorization code for an unverified email.
**Steps:**
1. Seed victim account on laravelshift.com via GitHub/Bitbucket using email X.
2. Create GitLab account with email X, never confirm it.
3. Start 'Sign in with GitLab' on LaravelShift; observe the email-verification block page.
4. Replay `POST /oauth/authorize` with `client_id`, `redirect_uri`, `state`, `response_type=code`, valid CSRF/cookies.
5. Receive 302 to `https://laravelshift.com/auth/gitlab/callback?code=...`.
6. Visit callback URL; logged into victim account.
**How found:** Noticed the UI enforced email verification before OAuth grant, hypothesized the check lived in the frontend flow rather than the backend handler, and replayed the authorize POST directly to confirm.
**Exploitation:** Attacker registers a GitLab account with a victim's email without confirming it, then directly POSTs the OAuth authorize request (bypassing the UI gate) to obtain a valid authorization code. The third-party relying party trusts GitLab's email as verified and merges the OAuth identity with the existing account, yielding account takeover.
**Escalation:** Same technique extends to internal company pages that gate access on `@domain.com` email suffix, granting unauthorized internal access.
**Insight:** When a UI shows a gate ('verify email first'), test whether the underlying endpoint enforces it independently—replay the final POST directly with valid CSRF/state to see if the check is UI-only.

## Proof of concept (copied exactly from the original report)

**Raw POST to /oauth/authorize bypassing email verification**

```
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=
```

