Users can import members from projects that they are not a maintainer on through API
The API endpoint for importing project members did not enforce that the requester is a maintainer on the target project, unlike the UI. An attacker with maintainer access to one project could import members from any visible project, including private ones where they only had Guest access.
GitLab
Originally disclosed on GitLab
- Fixed in 2 months
- Disclosed after 2 months
HackerOne report #1356100 by joaxcar on 2021-10-01, assigned to GitLab Team:
Report | How To Reproduce
Report
Summary
Security patch 14.3.1 fixed (link to patch notes and link to commit) an issue where a maintainer in one project could import members from another project while not being a maintainer in that target project. This is now enforced in the GitLab UI and any requests putting the target project as a project where the user is not maintainer will fail.
This check is not enforced if the same user uses the API endpoint /projects/:id/import_project_members/:project_id documentation. As long as the user have maintainer access to the project with id :id the users can import members from any target :project_id as long as it is visible for the user. That is all public projects and any private project where the user have a role Guest or higher.
Steps to reproduce
-
Create a two users
user1anduser2 -
Log in as
user1and create a public projectproject1in the users namespaceuser1 -
Make a note of the project ID, we call it
ID1 -
Log in as
user2and create a private projectproject2 -
Make a note of the project ID, we call it
ID2 -
Go to https://gitlab.com/-/profile/personal_access_tokens and create an access token for
user2, lets call itTOKEN1 -
Send this request in a terminal (replacing <TOKEN>, <ID2> and <ID1>)
curl --request POST --header "PRIVATE-TOKEN: <TOKEN1>" "https://gitlab.com/api/v4/projects/<ID2>/import_project_members/<ID1>" -
Go to https://gitlab.com/user2/project2/-/project_members and verify that
user1is imported from the public project whereuser2is not a member
Impact
Importing members is supposed to be an action that is restricted to users who are maintainers on both target projects. The API allows users to bypass this restriction.
What is the current bug behavior?
The API endpoint does not validate the role of the requester as the UI does
What is the expected correct behavior?
The API should work as the functionality in the UI
Output of checks
This bug happens on GitLab.com
Impact
Importing members is supposed to be an action that is restricted to users who are maintainers on both target projects. The API allows users to bypass this restriction.
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 lacked the same authorization check that was added to the UI, allowing any maintainer of the source project to import members from any visible target project.
Impact
A user with maintainer access to one project could import members from any visible project, including private projects where they only had Guest access, bypassing the intended restriction.
What the attacker needed
Maintainer access to one project; personal access token; target project visible to attacker
The fix
The API should enforce the same maintainer check as the UI, requiring maintainer access on both projects.
How it was found
- Create two users, user1 and user2.
- Log in as user1 and create a public project project1.
- Note the project ID as ID1.
- Log in as user2 and create a private project project2.
- Note the project ID as ID2.
- Create a personal access token for user2.
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, importing members from another project should only be allowed if you are a maintainer on both projects. The web interface checked this, but the API did not, so someone could use the API to pull in members from projects they should not have access to.
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.