Skip to content
Access control Disclosed report Intermediate

Service account not deleted when namespace is deleted allowing access to internal projects

A service account created for a group is not deleted when the group is deleted, leaving an orphaned account. A removed user can still use the service account's token to access internal projects.

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 #2040822 by joaxcar on 2023-06-27, assigned to GitLab Team:

Report | How To Reproduce

Report

Summary

The new service account feature is subject to the same issue as project and group access tokens previously was, that a service account connected to a namespace is not deleted when the namespace is deleted. See a long discussion on the topic here https://hackerone.com/reports/1199561

The problem is that a user who owns a group on an instance can create a service account and if an admin removes the user and all its projects and groups the removed user will still have access to internal projects through the (now "orphant") service account.

As with group and project access tokens these namespace connected service accounts should be deleted if the namespace is deleted.

Steps to reproduce

Use either a group with unlimited trial on gitlab.com or use a self hosted premium server. Also make sure to have an access token generated for the user you are testing with.

  1. Create a new group (or subgroup), take note of the group ID
  2. Run this in a terminal
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/<group id>/service_accounts"  
  1. Take a note of the service account ID
  2. Now run this command to create a token for the service account
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/<group id>/service_accounts/<service account id>/personal_access_tokens" --data "scopes[]=api" --data "name=service_accounts_token"  
  1. Take a note of the generated access token
  2. Now use the new access token towards the api
curl --header "PRIVATE-TOKEN: <service_access_token>" "https://gitlab.example.com/api/v4/user"  

There is a bug telling you that the user need to accept terms and services, it does not matter, you can see that the service account exists.
7. Now go to https://gitlab.com/groups/NameOfGroup/-/edit and scroll down to advanced, expand it a scroll down to "delete group". Delete the group
8. Do the request from step 6 again and see that the user still exist even when the group is gone

This PoC shows that the issue exists. A more involved PoC would include deleting the user and all its groups, and then prove that the service account is still present. I can write up the steps if needed.

Impact

A deleted user can use service accounts as a back door to access internal projects after being removed from the instance. The service accounts will have full read access to internal projects and can also create issues and other integrity affecting actions.

How is it working today

Deleting a namespace does not delete the connected service accounts

How it should work

Deleting a namespace should delete any connected service account

Impact

A deleted user can use service accounts as a back door to access internal projects after being removed from the instance. The service accounts will have full read access to internal projects and can also create issues and other integrity affecting actions.

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

Impact

A deleted user can use the orphaned service account to access internal projects, including reading data and creating issues.

What the attacker needed

A GitLab.com group with trial or self-hosted Premium; an access token for the user; ability to create service accounts

The fix

Deleting a namespace should also delete any connected service accounts.

How it was found

  1. Create a new group and note its ID.
  2. Use the API to create a service account for the group.
  3. Note the service account ID.
  4. Create a personal access token for the service account.
  5. Use the token to confirm the service account exists.
  6. Delete the group via the web interface.

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 service account is a special user account for automated tasks. When a group is deleted, its service account should also be removed, but it isn't. This means someone who no longer has access can still use that account to see internal projects.

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.