Authentication via the device authorization grant flow should obey OAuth client scopes

⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.

Summary

GitLab's implementation of the device authorization grant OAuth flow could be hardened to frustrate phishing and allow the identification of systematic abuse by security. Phishing via the device authorization requires user interaction but may lead to a threat actor-controlled access token, posing a risk to the integrity and confidentiality of customer and team member data.

See https://gitlab.com/gitlab-org/gitlab/-/issues/542008 for more context.

A client can request an access token with a scope that the OAuth application doesn't normally allow. This can allow privilege escalation in case of a compromise.

Steps to reproduce

  1. Create an OAuth Application and limit the scope to read_user
  2. Go through the device authorization grant flow and request api scope
  3. Get the token anyway

Example Project

What is the current bug behavior?

Application scope is not respected

What is the expected correct behavior?

Requests for scopes that aren't allowed by the OAuth application should be rejected as they are with other flows

Relevant logs and/or screenshots

Application with read_user

image

Request api

image

Access token granted with api scope

{"access_token":"REDACTED","token_type":"Bearer","expires_in":7200,"refresh_token":"REDACTED","scope":"api","created_at":1747404895}

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes


cc @gitlab-com/gl-security/appsec

Edited by Dominic Couture