Email generation for bots leads to the inability to create project/group access tokens
GitLab generates predictable email addresses for bot users that are created when project or group access tokens are made. An attacker could link these email addresses to their own account without confirmation, preventing the creation of any project or group access tokens.
GitLab
Originally disclosed on GitLab
- Fixed in 11 days
- Disclosed after 11 days
HackerOne report #1861701 by 0xn3va on 2023-02-03, assigned to @rshambhuni:
Report | Attachments | How To Reproduce
Report
Summary
Gitlab allows users to create access tokens for specific projects or groups (you can find more details at https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html and https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html). It is implemented via the creation of a bot user and a PAT token for them. Since Gitlab creates users, it assigns email addresses to them using the following scheme:
project{project_id}_bot@noreply.{Gitlab.config.gitlab.host}
group{project_id}_bot@noreply.{Gitlab.config.gitlab.host}
If there is more than one project/group access token, it adds a number to the end project{project_id}_bot{number}[@]noreply.{Gitlab.config.gitlab.host}. However, it does not happen if the address is occupied by another user. In other words, if you link the address project{project_id}_bot@noreply.{Gitlab.config.gitlab.host} to your account (you do not need to confirm it) you will not be able to create any project access tokens due to the following error:
[REDACTED]
As a result, it is very easy to disable the ability to create access tokens for any project or group. Moreover, I didn't find any limits on the amount of linked emails, I was able to linked more than 100 emails to a single account.
Steps to reproduce
-
Open gitlab.com and login
-
Create a project or a group
-
Find and keep project/group ID
-
Go to User Settings > Emails
-
Link the following email to your account (you do not need confirmation):
for project:
project{Project_ID}[email protected]or for group:
group{Group_ID}[email protected] -
Go to the project/group
-
Go to Settings > Access Tokens
-
Try to create an access token; it will return an error
What is the current bug behavior?
Bots use predictable email addresses and do not change an email address if there is no access token for "previous" email address.
What is the expected correct behavior?
Bot emails have a random prefix/suffix, or bots iterate the address, whether there is "previous" access token or not.
Relevant logs and/or screenshots
PoC: [REDACTED]
Output of checks
This bug happens on GitLab.com
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 bot email addresses are predictable and the system does not verify email ownership or handle collisions when the address is already linked to another user.
Impact
An attacker could prevent the creation of project or group access tokens for any project or group.
What the attacker needed
A GitLab account; ability to link unconfirmed emails
The fix
Bot emails should have a random prefix/suffix, or bots should iterate the address regardless of whether there is a previous access token.
How it was found
- Open gitlab.com and log in.
- Create a project or a group.
- Find and keep the project or group ID.
- Go to User Settings > Emails.
- Link the email address project{Project_ID}[redacted] (or group{Group_ID}[redacted]) to your account without confirmation.
- Go to the project/group Settings > Access Tokens and try to create an access token; it will return an error.
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.
When you create an access token for a project or group in GitLab, GitLab automatically creates a special 'bot' user account for it. That bot account gets an email address that is easy to guess, like [redacted] The problem is that anyone can add that email address to their own GitLab account without proving they own it, and then GitLab can't create the bot account because the email is already taken. This blocks the legitimate creation of access tokens for that project or group.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.