Skip to content
Access control Disclosed report Intermediate

External user can rotate project token via POST /api/v4/projects/{projectId}/access_tokens/{tokenId}/rotate to gain new token with Internal access

An external user could rotate a project access token created by an internal user, and the resulting token retained internal privileges, allowing the external user to access all internal projects. This could lead to cloning internal repositories and leaking sensitive data.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 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 #2888260 by aituglo on 2024-12-09, assigned to @ngeorge1:

Report | Attachments | How To Reproduce

Report

Summary

A user with external access can rotate a project token created by an internal user in order to access all the external projects and access.

Steps to reproduce

You will need two users, an internal ( simple user ) user who can create projects called INTERNAL and an external user called EXTERNAL.

With INTERNAL user:

  • Create a new private project, and invite EXTERNAL into it as a maintainer :
CleanShot_2024-12-09_at_10.23.52.png
CleanShot_2024-12-09_at_10.23.52.png From the original on GitLab
  • Navigate to the settings of the project in access token and create a new token for the project with all the scope you want but mainly api and read_api :
CleanShot_2024-12-09_at_10.24.27.png
CleanShot_2024-12-09_at_10.24.27.png From the original on GitLab

With EXTERNAL user:

  • Navigate to the project and go to the access token settings. You can rotate the token created by INTERNAL and use it with the gitlab api to access all the internal projects and clone them.
CleanShot_2024-12-09_at_10.28.05.png
CleanShot_2024-12-09_at_10.28.05.png From the original on GitLab
  • You can now for instance make this request to access all the projects on the gitlab instance, including the internal ones.
BURP
GET /api/v4/projects HTTP/1.1  
Host: localhost:3000  
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0  
Accept: application/json, text/plain, */*  
PRIVATE-TOKEN: glpat-***  
CleanShot_2024-12-09_at_10.29.34.png
CleanShot_2024-12-09_at_10.29.34.png From the original on GitLab
Impact

With this issue, an external user can now access all the internal repository and clone them, access them.

It can then leak important data. With the scope related to the access token, the user can also create new internal project, interact with them, post issues and so on.

Examples
What is the current bug behavior?

When an external user create an access token on a project, this token is related to a new bot user with the flag external enabled. It's not the case when the token is created by an internal user and then rotated by the external user.

What is the expected correct behavior?

If it's an external user that rotate the token, the bot user should get the external flag enabled.

Results of GitLab environment info
System information  
System:		  
Proxy:		no  
Current User:	aituglo  
Using RVM:	no  
Ruby Version:	3.2.4  
Gem Version:	3.5.23  
Bundler Version:2.5.11  
Rake Version:	13.0.6  
Redis Version:	7.0.14  
Sidekiq Version:7.2.4  
Go Version:	go1.23.2 darwin/arm64

GitLab information  
Version:	17.7.0-pre  
Revision:	3bfc0f5fa0a  
Directory:	/Users/aituglo/hacking/bb/gitlab/gdk/gitlab  
DB Adapter:	PostgreSQL  
DB Version:	14.9  
URL:		http://127.0.0.1:3000  
HTTP Clone URL:	http://127.0.0.1:3000/some-group/some-project.git  
SSH Clone URL:	ssh://[email protected]:2222/some-group/some-project.git  
Elasticsearch:	no  
Geo:		no  
Using LDAP:	no  
Using Omniauth:	yes  
Omniauth Providers: 

GitLab Shell  
Version:	14.39.0  
Repository storages:  
- default: 	unix:/Users/aituglo/hacking/bb/gitlab/gdk/praefect.socket  
GitLab Shell path:		/Users/aituglo/hacking/bb/gitlab/gdk/gitlab-shell

Gitaly  
- default Address: 	unix:/Users/aituglo/hacking/bb/gitlab/gdk/praefect.socket  
- default Version: 	17.5.0-rc1-338-gc808ff0c9  
- default Git Version: 	2.47.0  

Impact

With this issue, an external user can now access all the internal repository and clone them, access them.

It can then leak important data. With the scope related to the access token, the user can also create new internal project, interact with them, post issues and so on.

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, when a project access token is rotated, the associated bot user's external flag is not updated to match the rotating user's external status, so the token retains the original creator's internal privileges.

Impact

An external user could access all internal repositories, clone them, and potentially leak sensitive data; depending on token scope, they could also create and interact with internal projects.

What the attacker needed

Two users: one internal, one external; Internal user creates project and token; External user is maintainer on project

The fix

The expected behaviour is that the bot user should get the external flag enabled if the rotating user is external.

How it was found

  1. As INTERNAL, create a new private project and invite EXTERNAL as a maintainer.
  2. As INTERNAL, navigate to the project's access token settings and create a new token with api and read_api scopes.
  3. As EXTERNAL, navigate to the project's access token settings and rotate the token created by INTERNAL.
  4. Use the rotated token to make API requests, such as listing all projects, to access internal projects.

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.

In GitLab, users can be marked as 'external', which normally limits what they can see. Project access tokens are like passwords that let programs interact with GitLab. The bug meant that if an external user rotated a token originally made by an internal user, the new token didn't get the external restriction, so the external user could see everything an internal user could.

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.