Skip to content
Business logic Disclosed report Beginner

Incorrect admin scope mentioned in the UI when a non-admin user creates a personal access token using a crafted request

A non-admin user could add admin-only scopes to a personal access token creation form, and the UI would display the token as having those scopes even though the backend did not grant them. This could cause confusion but did not actually give admin privileges.

GitLab

Originally disclosed on GitLab

  • Fixed in 13 months
  • Disclosed after 13 months

HackerOne report #1836166 by the_machine_ on 2023-01-16, assigned to @ameyadarshan:

Report | Attachments | How To Reproduce

Report

Summary

On https://gitlab.com/-/profile/personal_access_tokens, a user can create a new personal access token (PAT) for the GitLab API. Thereby the user can select different scopes (e.g. 'api', 'read_api', ...). The page only contains the scopes that are available for the current user. There are two scopes for admins that are not displayed for non-admins. However a non-admin can just manually extends the creation form (HTML) with the scopes for admins and select them as well. If the non-admin submits the creation for with the additional admin scopes, a personal access token is created and the UI shows that PAT having admin scopes (when in fact it does not).

Steps to reproduce

(Step-by-step guide to reproduce the issue, including:)

  1. Sign in to GitLab as a non-admin.
  2. Visit https://gitlab.com/-/profile/personal_access_tokens to create a personal access token.
  3. Extend the checkbox list of scopes with the 'sudo' and 'admin_mode' scopes (scopes for admins only). See this section below on how to do that as a proof-of-concept.
  4. Check the 'sudo' and 'admin_mode' scopes and submit the form.
  5. The UI lists that the personal access token has 'sudo' and 'admin_mode' scopes when it fact it does not.
Impact

Incorrect admin scope mentioned in the UI when a non-admin user creates a personal access token using a crafted request. This can lead to confusion on the user end.

What is the current bug behavior?

The selected scopes (from UI) are not validated in the backend.

What is the expected correct behavior?

The selected scopes (from UI) should be validated in the backend. It should be forbidden for non-admins to create a personal access token with scopes for admins.

Relevant logs and/or screenshots

HTML to extend the checkbox list of scopes with the 'sudo' and 'admin_mode' scopes:

<div class="gl-form-checkbox custom-control custom-checkbox">  
<input id="personal_access_token_scopes_sudo" data-qa-selector="sudo_checkbox" class="custom-control-input" type="checkbox" value="sudo" name="personal_access_token[scopes][]">  
<label data-qa-selector="sudo_label" class="custom-control-label" for="personal_access_token_scopes_sudo"><span>sudo</span><p class="help-text" data-testid="pajamas-component-help-text">Grants permission to perform API actions as any user in the system, when authenticated as an admin user.</p></label>  
</div>  
<div class="gl-form-checkbox custom-control custom-checkbox">  
<input id="personal_access_token_scopes_admin_mode" data-qa-selector="admin_mode_checkbox" class="custom-control-input" type="checkbox" value="admin_mode" name="personal_access_token[scopes][]">  
<label data-qa-selector="admin_mode_label" class="custom-control-label" for="personal_access_token_scopes_admin_mode"><span>admin_mode</span><p class="help-text" data-testid="pajamas-component-help-text">Grants permission to perform API actions as an administrator, when Admin Mode is enabled.</p></label>  
</div>  
Output of checks

This bug happens on GitLab.com

Impact

Incorrect admin scope mentioned in the UI when a non-admin user creates a personal access token using a crafted request

Attachments

How To Reproduce

Please add reproducibility information to this section:

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

The backend did not validate that the requested scopes were allowed for the user's role, so it accepted admin scopes from a non-admin and displayed them, though it did not enforce them.

Impact

The UI incorrectly displayed admin scopes on a token, which could confuse users, but the token did not actually have those privileges.

What the attacker needed

A non-admin GitLab account; ability to modify the HTML form

The fix

The backend should validate the selected scopes and forbid non-admins from creating tokens with admin scopes.

How it was found

  1. Sign in to GitLab as a non-admin user.
  2. Go to the personal access tokens page.
  3. Modify the page to add the admin-only scopes 'sudo' and 'admin_mode' to the list of checkboxes.
  4. Select those scopes and submit the form.
  5. Observe that the UI shows the token as having those admin scopes, even though it does not.

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.

A personal access token is like a password for programs to access an account. The web page only showed certain permission options to normal users, but a user could edit the page to add admin-only options. The system accepted the request and showed the token as having admin permissions, but it did not actually grant them, so it was only a display mistake.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.