Real World GitLab Account Take Over
A GitLab server running a vulnerable version allowed password reset requests to include multiple email addresses, so a reset token was sent to both the victim's and the attacker's addresses. The attacker could then use the token to reset the victim's password and take over the account.
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
The target was a company that provides VoIP solutions, with clients that include government organisations, banks and telecom providers. The engagement was external, and the scope covered essentially every internet asset the company owned. The asset that mattered here was git.target.com, a GitLab CE instance that might hold accounts of the company's R&D staff. GitLab's password reset feature is the normal entry point: a user submits an email address to /users/password, and GitLab mails a reset link containing a token to that address.
Setup
No valid account was available at the start: the researcher had no client or employee credentials. The interesting assets found during reconnaissance were:
- target.com
- admin.target.com
- api.target.com
- staging.target.com
- cl.target.com (clients login)
- git.target.com
Fuzzers were left running in the background against most of these addresses while the researcher turned to the git subdomain. The tools used later were theHarvester, hunter.io, intelx.io, viewDNS.info, grep.app, a public PoC script for CVE-2023-7028, and TruffleHog.
Finding it
Visiting git.target.com showed a normal GitLab CE login page, with a Register now link at the bottom. Registration was open: the real registration page loaded, and an account could be created. However, no activation email arrived and the new account stayed pending administrator approval, so it was not usable.

With the recent GitLab CVEs in mind, the researcher checked whether the instance was vulnerable to CVE-2023-7028, an account takeover. The vulnerable versions listed in the report are:
- 16.1-16.1.5
- 16.2-16.2.8
- 16.3-16.3.6
- 16.4-16.4.4
- 16.5-16.5.5
- 16.6-16.6.3
- 16.7-16.7.1
The version was fingerprinted from the login page source: the page exposes a revision ID, which was looked up in the GitLab FOSS repository and mapped to a release. That gave GitLab 16.2.1, which is on the vulnerable list.
Exploitation
Step 1: understand the flaw
According to the vulnerability description, exploitation works by triggering the Reset Password functionality with two email addresses: one belonging to a valid GitLab user and one belonging to the attacker. The vulnerable code is in spec/controllers/password_controller_spec.rb. It expects a POST request with an email address parameter but does not validate that the list contains only one address. The result is that the GitLab server sends the reset token to both addresses, so the attacker takes over the account as soon as they click the link in their own mailbox.
Step 2: build the request
The attacker sends a POST request to /users/password containing:
- a valid GitLab account email address (for example
[redacted]) - the attacker's email address
- an
authenticity_tokenfor CSRF protection
The report shows the request in an image rather than as text, so the exact body is not reproduced here.
Step 3: harvest employee addresses
The remaining requirement was a list of employee email addresses. The first check was the target's MX record, which confirmed the company uses its own domain for email. theHarvester was then run against the domain but returned only 6 results, none of which could be confirmed as relevant to the GitLab server. Other sources were used instead, all requiring an account:
- hunter.io
- intelx.io
- viewDNS.info
- grep.app (searching for the target's email in GitHub repositories)
This produced more than 80 employee email addresses.
Step 4: automate the reset requests
Each request needs a freshly issued CSRF token, so Burp Intruder was not suitable. The researcher took a public PoC for CVE-2023-7028 from GitHub and added a loop that reads all addresses from a text file, plus a two minute sleep between iterations so that a recovery email in the attacker mailbox could be noticed before the script moved on to take over further accounts.
Step 5: take over the account
A reset email from GitLab arrived in the attacker mailbox. The link led to the reset password page, a new password was submitted, and the login page accepted it. Logging in gave access to all the company projects without any permission issues.
Step 6: pivot with extracted secrets
All of the company's code was downloaded and scanned with TruffleHog to extract API keys and hardcoded credentials. Those credentials gave access to other assets, particularly the API and clients subdomains: the whole company API was usable with high permissions, and an admin user could be created in the clients panel.
Root cause
The password reset controller accepts a list of email addresses and does not enforce that it contains exactly one. The reset token is therefore generated and mailed to every address supplied, including one the attacker controls. Each request needs a freshly issued CSRF token, so a simple repeat tool was not suitable.
Impact
Any GitLab user whose address appears in the harvested list could be taken over; the account that was taken over had access to all company projects. From there, secrets in the source code extended the compromise to the API and the clients panel, where an admin account could be created. The report does not state how many accounts were ultimately taken over.
Fix
The report does not describe the remediation.
Variants to test
- Submit the reset form with the email parameter repeated or comma separated, for example
email=[redacted]&email=[redacted]. A positive result is a reset mail arriving at the attacker address. - Try the same duplication on other mail-sending features (invitations, confirmations, notifications) that take an address parameter. A positive result is a message delivered to an address the requester supplied alongside the legitimate one.
- Fingerprint GitLab from the login page revision ID and map it to a release before testing. A positive result is a version inside a known vulnerable range.
- Check whether self-registration is open even when accounts stay pending approval, since the registration flow itself may expose other behaviour. A positive result is a working registration page on an instance that should not allow it.
What happened, in plain words
A security researcher was hired to test how safe a company's websites and servers were. The company sells VoIP solutions, which means the software that lets people make phone calls over the internet instead of through a traditional phone line. Its customers include government organisations, banks and telecom providers, so a break-in here would matter a lot.
The researcher was allowed to look at almost everything the company runs on the internet. One of those things was a GitLab server. GitLab is a website where programmers store and share the code they write, a bit like a shared online filing cabinet for software projects. The company's research and development staff may have had accounts on it.
GitLab, like most websites with user accounts, has a "forgot my password" button. You type your email address, and GitLab sends you a link that lets you set a new password. That link contains a secret code, called a token, so that only the person who owns the mailbox can use it.
The researcher found that this particular GitLab was running an old version with a known bug. The bug meant that if you asked for a password reset and gave two email addresses instead of one, GitLab would happily send the reset link to both of them. So an attacker could put a victim's address first and their own address second, and GitLab would mail the secret reset link to the attacker as well. Clicking that link let the attacker set a new password for the victim's account. That is called an account takeover: someone else ends up controlling your account.
Once inside, the researcher could see every project the company had stored on GitLab. They downloaded the code and searched it for passwords and keys that programmers had accidentally left in it. Those secrets then opened the door to other parts of the company's systems, including its API and its customer login panel, where the researcher could even create an administrator account for themselves.
This article walks through the whole story step by step, explaining each idea as it comes up. You only need to know how to use a browser.
The target and the rules of the game
The company asked for an external engagement. That means the researcher tested from the outside, over the internet, the way any stranger would, rather than sitting inside the company's office network. The scope, the list of things the researcher was allowed to test, was pretty much every internet asset the company owned.
An asset here just means a machine or service reachable on the internet: a website, a login page, an API, a mail server. Before touching anything, a tester agrees with the company which assets are in scope, so that nobody accidentally attacks a system that belongs to someone else.
The first day was about reconnaissance. Reconnaissance means gathering information before attacking: finding out which servers exist, what software they run, and which ones look interesting. It is the online equivalent of walking around a building and noting which windows are open before trying any doors.
The most interesting assets that were found are:
- target.com
- admin.target.com
- api.target.com
- staging.target.com
- cl.target.com (clients login)
- git.target.com
Each of these is a subdomain. A domain is the name of a website, like target.com. A subdomain is a name placed in front of it to point at a different service, so git.target.com is a separate machine from admin.target.com, even though both belong to the same company. Think of the domain as a building's street address and the subdomains as different departments inside it.
cl.target.com is labelled clients login, so it is where the company's customers sign in. git.target.com is the GitLab server. api.target.com is an API, which stands for Application Programming Interface. An API is the part of a service that other software talks to, rather than a human with a browser. When a mobile app shows you a list of orders, it is usually asking an API behind the scenes. If an attacker gets hold of the keys that let software talk to an API, they can often do everything the software could do, at machine speed.
The researcher had no valid user account, neither as a client nor as an employee. So instead of logging in, they let their fuzzers run in the background on most of the addresses. A fuzzer is a program that automatically tries many variations of a request, looking for something unusual: a page that should not exist, an error message, a different response. It is like trying many keys on a lock very quickly. While those ran, the researcher turned to the git subdomain, because a GitLab server is where source code lives, and source code is often where secrets live too.
GitLab enumeration
Visiting git.target.com showed a normal GitLab CE login page. GitLab CE is the Community Edition, the free version of GitLab. Enumeration means listing and describing what you find: which software, which version, which features are switched on.

The first thing that stood out was the bottom of the page: a Register now link. That link means the server allows anyone to create an account, which is not always the case. The researcher wondered whether a self-made account could reach other users' projects. In previous engagements, clicking such a link had sometimes led to a block: a 403 error, an Access Denied page, or some other error. A 403 is the standard web response meaning "you are not allowed to see this".
Here, luckily, the real registration page loaded. So an account could be created. But no activation email arrived, and the new account stayed pending the approval of the GitLab administrator. In other words, the door let you in to a waiting room, but a member of staff had to unlock the next door, and nobody did. The account was not usable.
That dead end is worth noting: open registration looked promising, but it did not by itself give access. The researcher moved on to a different idea.
Checking the version
Everyone in security had heard about the recently published CVEs for GitLab, so it was time to check whether one of them applied here. A CVE is a Common Vulnerabilities and Exposures identifier: a public catalogue number given to a specific, documented security flaw. When someone says "CVE-2023-7028", they mean one particular bug, written down once, so that everyone in the world is talking about the same thing.
The relevant one was an account takeover, CVE-2023-7028. The vulnerable GitLab versions listed are:
- 16.1-16.1.5
- 16.2-16.2.8
- 16.3-16.3.6
- 16.4-16.4.4
- 16.5-16.5.5
- 16.6-16.6.3
- 16.7-16.7.1
Read that list as ranges. The first line means every version from 16.1 up to and including 16.1.5 is affected. Software versions are written as numbers separated by dots, and each new release fixes bugs, so a range like this tells you exactly which releases still contain the flaw. If the server runs a version inside one of these ranges, it is exposed.
So the next question was: which version is this server running? Going back to the login page, the researcher viewed the page source code. The source code is the raw text a browser receives and turns into the page you see; you can view it in any browser with a right-click and "View page source". Somewhere in it was a revision ID. A revision ID is an internal identifier for the exact build of the software, a bit like a serial number stamped inside a device.
Taking that revision ID to the GitLab FOSS repository and searching for it showed a result. FOSS stands for Free and Open Source Software: the public code repository where GitLab publishes its source, so anyone can look things up. Searching the revision ID there also disclosed the GitLab version. That gave GitLab 16.2.1, which is on the vulnerable list.
This is a common and important step. You do not guess a version; you find a piece of information the server gives out freely, and you look it up in a public place. The server was effectively telling anyone who looked which version it ran.
Diving into CVE-2023-7028
According to the vulnerability description, the exploitation occurs by triggering the Reset Password functionality, combining two email addresses: one for a valid GitLab user, and one for the attacker's email address.
Let us unpack that. The Reset Password feature is the "forgot my password" flow described earlier. Normally it takes one address, checks that an account exists for it, creates a one-time token, and emails a link containing that token to the address. The token is the proof that whoever clicks the link controls the mailbox. If the token also lands in the attacker's mailbox, the attacker has the proof too.
The vulnerable piece of code resides in spec/controllers/password_controller_spec.rb. The code expects a POST request containing an email address as a parameter, but without validating that there aren't multiple email addresses in the list.
Two terms there. A POST request is one of the ways a browser or program sends data to a server. When you fill in a form and press submit, your browser usually sends a POST request carrying the values you typed. A parameter is one of those values, sent as a name and a value, like email=[redacted]. Validation means checking that the data makes sense before acting on it. Here the code checked that an email address was present, but not that there was only one. It is like a bouncer who checks you have a ticket but not that you only have one, so you can hand a second ticket to a friend.
The exploitation causes the GitLab server to send an email with a reset token to both email addresses, ending with an account takeover the minute the attacker clicks the link in their mailbox.
In order for the exploitation to work, the attacker needs to send a POST request to /users/password along with:
- a valid GitLab account email address (like [redacted])
- the attacker's email address
- authenticity_token for CSRF protection
/users/password is the address on the server that handles password resets. The third item needs explaining. CSRF stands for Cross-Site Request Forgery. It is an attack where a malicious website makes your browser send a request to another site while you are logged in there, without you meaning to. To stop it, sites include a hidden value in their forms called an authenticity token, or CSRF token. The server checks that the token matches your session before accepting the form. A session is the server's memory of who you are while you are logged in, usually kept alive by a cookie, a small piece of data your browser stores and sends back with each request. The CSRF token is like a numbered cloakroom ticket that the server issued to you and expects to see again; a stranger's website cannot guess it.
Eventually, the request should look like this:
The report shows this request in an image rather than as text, so the exact body is not reproduced here.
So now there was a vulnerable GitLab server that might be used to take over an account of one of the R&D staff. The only missing ingredient was a list of employees' email addresses.
Harvesting email addresses
There are many ways to get valid email addresses of a company, especially if they are under the company's own domain. Harvesting here means collecting addresses from public sources, not stealing them.
First, the researcher checked the MX record of the target. An MX record is a piece of the internet's address book, the Domain Name System, that says which mail server accepts email for a domain. Looking it up tells you whether the company runs its own mail or outsources it. Here it confirmed the company uses its own domain for email, so addresses like [redacted] are real and delivered internally.
Next, theHarvester was put to work. theHarvester is a free tool that searches public sources for email addresses, hostnames and similar details belonging to a domain. It automates what you could do by hand: searching the web for mentions of the company's domain.
theHarvester found only 6 results, and the researcher could not be sure that one of them was relevant to the GitLab server. Six addresses is far too few to work with, and none was confirmed to belong to a GitLab user. So other sources were used, all of which need an account:
- hunter.io
- intelx.io
- viewDNS.info
- grep.app (searching for the target's email in GitHub repositories)
Each of these is a website that indexes public information. hunter.io specialises in finding company email addresses. intelx.io searches large collections of leaked and public data. viewDNS.info offers lookups about domains. grep.app searches code published on GitHub, which is useful because programmers sometimes leave their work email in a public repository. Together they produced more than 80 email addresses of employees.
Why does this matter? Because the attack needs a valid address to aim at. The more real addresses you have, the better the chance that one of them belongs to someone with a GitLab account, and the more accounts you could potentially reach.
Exploiting the vulnerability: account takeover
There were now plenty of addresses to try. But each request also requires issuing a CSRF token, so it cannot be done with Burp Intruder or something like that. A custom script was needed.
Burp Intruder is a feature of Burp Suite, a popular tool for testing websites. Intruder takes a request and repeats it many times with different values in one position, which is exactly what you would want for trying 80 email addresses. The problem is the CSRF token: it changes for each session and must match, so a simple repeat with a fixed token fails. The tool would need a fresh token for each request, so a custom script was used instead. Hence a custom script: a small program that can log in, grab a token, build the request, send it, and repeat.
Luckily there are some good PoC scripts on GitHub for this vulnerability, like this one. PoC stands for Proof of Concept: a small piece of code that demonstrates a bug works, published so others can verify it. All that was needed was adding a small portion to the code to run a for loop that uses all the email addresses from a text file provided. A for loop is a programming instruction that repeats the same steps once for each item in a list, here once per address in the file. The researcher also added a 2 minute sleep between each loop, so they would be able to see first if a recovery email arrived in their mailbox before the script continued to take over more than one valid account.
That pause is a thoughtful detail. Without it, the script might fire at all 80 addresses in seconds and take over several accounts at once, which is messy and harder to report. With a two minute gap, the researcher could check the mailbox after each attempt and stop as soon as one worked.
And then it happened: the email arrived.
The reset email from GitLab landed in the attacker's mailbox. Clicking the link led immediately to the reset password page. A new password was submitted, and then the login page was visited. That is it: the researcher was in.
Why does this work? Because the server generated one reset token for the victim's account and sent it to both addresses. The attacker's mailbox received the same secret link the victim would have received. Whoever clicks first wins, and the attacker clicked first.
After logging in, the researcher was able to access all the company projects, without any permission issues. That means the compromised account belonged to someone with broad access, so the single takeover exposed everything stored on that GitLab.
Turning code into more access
The engagement continued by downloading all the company's code and extracting API keys and hardcoded credentials with TruffleHog. Hardcoded credentials are passwords, keys or tokens written directly into source code by a programmer, instead of being stored safely elsewhere. They are a classic mistake: the code gets shared, copied and sometimes published, and the secret travels with it. TruffleHog is a tool that scans code and looks for strings that look like secrets, such as API keys, and reports them.
An API key is a long string that acts like a password for software. If you have the key, the API treats your program as a trusted client. That is why finding keys in source code is so valuable: one leaked key can unlock a whole service.
The credentials extracted from the GitLab server were useful for accessing other assets of the company, especially the API and the clients subdomains. The researcher was able to use the whole company's API with high permissions, and to generate an admin user for themselves in the clients panel.
So the chain went like this: a bug in a password reset form let the researcher into one GitLab account; that account held all the company's source code; the code contained secrets; the secrets opened the API and the customer panel; and in the customer panel the researcher could create an administrator account. Each step was possible because of the previous one. This is what testers call pivoting: using one foothold to reach the next.
Target pwned, as the researcher put it.
Why it worked, and what to fix
The root cause is simple to state. The password reset handler accepts a list of email addresses and does not enforce that it contains exactly one. The reset token is therefore generated and mailed to every address supplied, including one the attacker controls. Each request also requires issuing a CSRF token, so a simple repeat tool could not be used. The protection was designed to stop other websites forging requests, not to stop the account owner's own browser from sending a strange one.
In everyday terms, the bouncer should check that you have exactly one ticket.
What a beginner can take from this
- Look before you touch. Reconnaissance found the subdomains, and one of them, the GitLab server, turned out to be the way in.
- Check versions. A login page can reveal which software and version is running, and public vulnerability lists tell you whether that version is known to be broken.
- Read the description of a bug carefully. Here the whole attack was one sentence: the reset form accepts more than one address.
- Gather the missing ingredient. The bug needed a valid address, so the researcher collected employee addresses from public sources.
- Automate when the tool does not fit. A changing CSRF token meant a custom script rather than a simple repeat tool.
- Follow the secrets. Source code often contains keys, and keys lead to other systems.
Glossary
- Account takeover: a situation where an attacker gains control of someone else's account, usually by obtaining their password or a reset link.
- API (Application Programming Interface): the part of a service that other software talks to, rather than a person using a browser.
- API key: a long secret string that software uses like a password to prove it is allowed to use an API.
- Asset: any machine or service a company runs on the internet, such as a website or a login page.
- authenticity_token: a hidden value in a web form that the server checks to confirm the request came from its own pages, used to prevent CSRF.
- Burp Intruder: a feature of the Burp Suite testing tool that repeats a request many times with different values in one position.
- Cookie: a small piece of data a website stores in your browser and receives back with each request, often used to remember that you are logged in.
- CSRF (Cross-Site Request Forgery): an attack where a malicious site makes your browser send a request to another site where you are logged in, without your intent.
- CSRF token: see authenticity_token; a value issued to your session so the server can tell your requests from forged ones.
- CVE (Common Vulnerabilities and Exposures): a public catalogue number given to a specific documented security flaw, so everyone refers to the same bug.
- Domain: the name of a website, such as
target.com. - Enumeration: listing and describing what a system exposes, such as its software, version and features.
- External engagement: a security test carried out from outside the company's network, over the internet.
- Fuzzer: a program that automatically sends many variations of a request to find unusual or unexpected responses.
- GitLab: a website where programmers store, share and manage source code for software projects.
- GitLab CE: the Community Edition, the free version of GitLab.
- Hardcoded credentials: passwords, keys or tokens written directly into source code instead of being stored safely elsewhere.
- MX record: a Domain Name System entry that says which mail server accepts email for a domain.
- Parameter: a named value sent with a request, such as
email=[redacted]. - Pivoting: using one foothold in a system to reach the next one.
- PoC (Proof of Concept): a small piece of code that demonstrates a vulnerability works, published so others can verify it.
- POST request: a way for a browser or program to send data to a server, typically when submitting a form.
- Reconnaissance: gathering information about a target before attacking, such as which servers exist and what software they run.
- Revision ID: an internal identifier for the exact build of a piece of software, like a serial number.
- Scope: the agreed list of systems a tester is allowed to test.
- Session: the server's memory of who you are while you are logged in.
- Source code: the raw text a browser receives and turns into the page you see, or the text programmers write to build software.
- Subdomain: a name placed in front of a domain to point at a different service, such as
git.target.com. - theHarvester: a free tool that searches public sources for email addresses and hostnames belonging to a domain.
- Token: a secret value, often one-time, used to prove identity or authorise an action, such as a password reset link.
- TruffleHog: a tool that scans code for strings that look like secrets, such as API keys.
- Validation: checking that data makes sense before acting on it, for example that a form contains exactly one email address.
- VoIP (Voice over IP): technology that carries phone calls over the internet instead of traditional phone lines.