Skip to content
Access control Disclosed report Beginner

Ability to list and delete impersonation tokens for your own user

A low-privileged user could list and revoke impersonation tokens that an administrator had created for their account, because the API did not restrict these actions to administrators. This allowed the user to disrupt administrative impersonation and learn when such tokens existed.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 months

HackerOne report #1205916 by jimeno on 2021-05-22, assigned to @dcouture:

Report | Attachments | How To Reproduce

Report

Summary

GitLab official documentation says only and Administrator can create an Impersonation Token. Otherwise users could deny them the use of this feature by continuously checking their Personal Access Tokens via the API and then revoking the generated impersonation token.

Impersonation tokens are a type of personal access token. They can be created only by an administrator, and are used to authenticate with the API as a specific user.

Suggested fix: only an administrator should be able to revoke an impersonation token. Also, impersonation tokens should not be listable by the impersonated user itself. Also, user won't see the impersonation token when browsing to their list of tokens via the GitLab UI.

Note: This report falls under the premise that only administrators should be able to revoke impersonation tokens.

Steps to reproduce

This was tested on a GitLab Ultimate instance.

  1. As Admin, browse to /admin/users, select your unprivileged user and click Impersonation Tokens section.

  2. Generate a new token scoped as you wish and note the name you set to it.

  3. As user, browse to your profile and create a new Personal Access Token (PAT) scoped to API access at least.

  4. As user, list your PATs.

    CONSOLE
    $ curl --header "PRIVATE-TOKEN: YOUR-PAT" "https://YOUR-INSTANCE/api/v4/personal_access_tokens" -s | jq .  
    
  5. Note the response includes the impersonation token created by the administrator user. Take a note of the token identifier.

  6. As user, revoke the impersonation token created by the administrator. Remember to replace the ID (6) with yours.

    CONSOLE
    $ curl -X DELETE --header "PRIVATE-TOKEN: YOUR-PAT" "https://YOUR-INSTANCE/api/v4/personal_access_tokens/6"  
    
recording-1621698195653.webm From the original on GitLab
Impact

Low privileged user is able to revoke impersonation token created by the instance administrator for their account. On the other hand, normal GitLab user is able to know when an administrator has created an impersonation token for their account.

Examples

N/A

What is the current bug behavior?

Low privileged user is able to revoke impersonation token created by the instance administrator for their account.

What is the expected correct behavior?

Only administrator user is able to revoke impersonation tokens. Impersonated user doesn't see the impersonation token when listing their Personal Access Tokens.

Relevant logs and/or screenshots

N/A

Output of checks

Only tested in GitLab Ultimate.

Results of GitLab environment info
CONSOLE
root@rigel:/# gitlab-rake gitlab:env:info

System information  
System:  
Proxy:		no  
Current User:	git  
Using RVM:	no  
Ruby Version:	2.7.2p137  
Gem Version:	3.1.4  
Bundler Version:2.1.4  
Rake Version:	13.0.3  
Redis Version:	6.0.12  
Git Version:	2.31.1  
Sidekiq Version:5.2.9  
Go Version:	unknown

GitLab information  
Version:	13.12.0-ee  
Revision:	12a3ec8fb4a  
Directory:	/opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:	PostgreSQL  
DB Version:	12.6  
URL:		https://rigel.wiki  
HTTP Clone URL:	https://rigel.wiki/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: auth0

GitLab Shell  
Version:	13.18.0  
Repository storage paths:  
- default: 	/var/opt/gitlab/git-data/repositories  
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell  
Git:		/opt/gitlab/embedded/bin/git

Impact

Low privileged user is able to revoke impersonation token created by the instance administrator for their account. On the other hand, normal GitLab user is able to know when an administrator has created an impersonation token for their account.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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

Likely the API endpoint for listing and revoking personal access tokens did not check whether the token belonged to an impersonation token and did not restrict the action to administrators.

What the attacker needed

GitLab instance with admin access; A low-privileged user account; Admin creates an impersonation token for that user

The fix

Only administrators should be able to revoke impersonation tokens, and impersonated users should not see them when listing personal access tokens.

How it was found

  1. As admin, create an impersonation token for an unprivileged user.
  2. As the user, create a personal access token with API scope.
  3. As the user, list personal access tokens via the API.
  4. Note the impersonation token in the response and its ID.
  5. As the user, revoke the impersonation token using its ID.

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.

An impersonation token is a special key that lets an administrator act as another user. The report found that a normal user could see and delete these keys even though only administrators should manage them. This meant the user could stop the administrator from using the token and could tell when one was created.

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.