Skip to content
Access control Disclosed report Intermediate

Users can create OAuth applications even if `User OAuth applications` is disabled by instance admin

The instance setting to disable user OAuth applications did not prevent users from creating group OAuth applications. An attacker could bypass the admin's restriction and create an OAuth application to obtain API access.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 months

⚠️ 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.

HackerOne report #2058026 by js_noob on 2023-07-08, assigned to @dcouture:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, a GitLab instance admin can disable OAuth applications for his instance which should block all users from creating OAuth applications. This is pretty obvious as the UI shows the following:

image.png
image.png From the original on GitLab

However, a user can still easily create group OAuth applications.

Steps to reproduce

As the instance admin:

  1. Spin up a GitLab instance
  2. Navigate to https://YOUR_DOMAIN/admin/application_settings/general#js-account-settings and disable User OAuth applications
image.png
image.png From the original on GitLab
  1. As a sanity check, verify that you can't create applications https://YOUR_DOMAIN/-/profile/applications

As any other user in that instance:

  1. Verify that you can't applications
  2. Create a new group
  3. Navigate to https://YOUR_DOMAIN/groups/GROUP/-/settings/applications, and verify that you can't create applications
  4. Send the following request, but change the vars according to your preferences (if you faced any issues constructing this request, take a look at the attached POC/video I used some workaround for this)
POST /groups/poc/-/settings/applications HTTP/2  
Host: gitlab-private.net  
Cookie: REDACTED
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8  
Accept-Language: en-US,en;q=0.5  
Accept-Encoding: gzip, deflate  
Referer: https://gitlab-private.net/groups/poc/-/settings/ci_cd  
Content-Type: application/x-www-form-urlencoded  
Content-Length: 347  
Origin: https://gitlab-private.net  
Upgrade-Insecure-Requests: 1  
Sec-Fetch-Dest: document  
Sec-Fetch-Mode: navigate  
Sec-Fetch-Site: same-origin  
Sec-Fetch-User: ?1  
Te: trailers

authenticity_token=ShGv3cieF3Hubv4jJrYEXBo_X5gbZPLf4uMRBHg7iDJFnIWhmKizn5g3_PN7LcIGmyV9kkvmmJKzfpy8dNAwEw&doorkeeper_application%5Bname%5D=My+App&doorkeeper_application%5Bredirect_uri%5D=https%3A%2F%2Fdocs.gitlab.com&doorkeeper_application%5Bconfidential%5D=0&doorkeeper_application%5Bconfidential%5D=1&doorkeeper_application%5Bscopes%5D%5B%5D=api  
  1. Verify the successful response (200 OK), now the HTML contains the necessary OAuth app info, either search in it or view it in a browser, it should look similar to the following

REDACTED

  1. At this point the application is created successfully bypassing the admin's setting, but if you want to confirm that this app works as expected, continue the steps
  2. Navigate to https://YOUR_DOMAIN/oauth/authorize?client_id=APP_ID&redirect_uri=https://docs.gitlab.com&response_type=code&state=test_state_123&scope=api (you might have to change vars if you changed them in step 7)
  3. Click authorize
  4. You should be redirected to a link similar to https://docs.gitlab.com/?code=authorization_code&state=test_state_123
  5. To get an auth token, send the following request
curl -X POST -d 'client_id=APP_ID&client_secret=APP_SECRET&code=CODE_FROM_STEP_12&grant_type=authorization_code&redirect_uri=https://docs.gitlab.com' https://YOUR_DOMAIN/oauth/token  
  1. The response should be similar to the following
{
    "access_token": "access_token",  
    "token_type": "Bearer",  
    "expires_in": 7200,  
    "refresh_token": "refresh_token",  
    "scope": "api",  
    "created_at": 1688831273  
}
  1. Now you can use the access_token to access the API, for example below
curl -X GET -H "Authorization: Bearer access_token" "https://gitlab-private.net/api/v4/projects/14"  
Examples/POC

REDACTED

Output of checks

I believe this also happens on gitlab.com but I can't verify.

Results of GitLab environment info
System information  
System:         Debian 11  
Proxy:          no  
Current User:   git  
Using RVM:      no  
Ruby Version:   3.0.6p216  
Gem Version:    3.4.13  
Bundler Version:2.4.14  
Rake Version:   13.0.6  
Redis Version:  6.2.11  
Sidekiq Version:6.5.7  
Go Version:     unknown

GitLab information  
Version:        16.1.1-ee  
Revision:       d3582d7719f  
Directory:      /opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:     PostgreSQL  
DB Version:     13.11  
URL:            https://gitlab-private.net  
HTTP Clone URL: https://gitlab-private.net/some-group/some-project.git  
SSH Clone URL:  [email protected]:some-group/some-project.git  
Elasticsearch:  no  
Geo:            no  
Using LDAP:     no  
Using Omniauth: yes  
Omniauth Providers: 

GitLab Shell  
Version:        14.23.0  
Repository storages:  
- default:      unix:/var/opt/gitlab/gitaly/gitaly.socket  
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell  

Impact

Users can create OAuth applications despite having them disabled by the instance admin, which allows other users to authenticate to the newly created app.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

REDACTED

How To Reproduce

Please add reproducibility information to this section:

Proposal

Based on additional discussion in this issue, we should verify that the Group OAuth applications are not managed by the User OAuth setting, and:

  • Remove the banner that indicates Group OAuth apps are disabled as they aren't controlled by the admin setting.
  • Update the User OAuth setting description label to state Allow users to register any application to use GitLab as an OAuth provider via their own account

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

Root cause

Likely, the setting that disables user OAuth applications was not enforced for group-level OAuth applications.

Impact

Users could create OAuth applications despite the admin's restriction, allowing other users to authenticate to the newly created app and potentially access API resources.

What the attacker needed

Admin disables user OAuth apps; attacker has a user account; attacker can create a group

The fix

The proposal is to verify group apps aren't controlled by the user setting and update the UI banner and label accordingly.

How it was found

  1. As admin, disable 'User OAuth applications' in general settings.
  2. As a regular user, create a new group.
  3. Send a crafted POST request to the group's applications endpoint.
  4. Verify the application is created despite the setting.
  5. Authorize the app and exchange the code for an access token.
  6. Use the token to access the API.

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.

OAuth applications let other apps access your account. An admin can turn off the ability for users to create such apps, but the report shows that users could still create them for groups, bypassing the restriction. This means the admin's security control was incomplete.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.