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.
-
As Admin, browse to
/admin/users, select your unprivileged user and click Impersonation Tokens section. -
Generate a new token scoped as you wish and note the name you set to it.
-
As user, browse to your profile and create a new Personal Access Token (PAT) scoped to API access at least.
-
As user, list your PATs.
CONSOLE $ curl --header "PRIVATE-TOKEN: YOUR-PAT" "https://YOUR-INSTANCE/api/v4/personal_access_tokens" -s | jq . -
Note the response includes the impersonation token created by the administrator user. Take a note of the token identifier.
-
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"
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
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:
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
- As admin, create an impersonation token for an unprivileged user.
- As the user, create a personal access token with API scope.
- As the user, list personal access tokens via the API.
- Note the impersonation token in the response and its ID.
- 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.