DOS: Taking down a 1k-users Gitlab EE self-manage instance by testing a malicious external wiki URL in a project's settings
GitLab's external wiki URL validation sends a request to the provided URL and automatically decompresses compressed responses without checking the Content-Encoding header. A malicious server can respond with a zip bomb, causing excessive memory consumption and taking down a 1k-user GitLab instance with just three requests.
GitLab
Originally disclosed on GitLab
- Fixed in 10 months
- Disclosed after 10 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 #2629934 by a92847865 on 2024-07-30, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
NOTE! Thanks for submitting a report! Please note that initial triage is handled by HackerOne staff. They are identified with a
HackerOne triagebadge and will escalate to the GitLab team any. Please replace all the (parenthesized) sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!
Summary
Gitlab allows adding a link to an external wiki to a project. Before saving external wiki's URL, user can validate if that URL is valid or not. To validate that URL, Gitlab application sends a request to the http server hosting external wiki. Due to lack of content-encoding validation, a malicious server can respond to Gitlab application with a zip-bomb (small gzip file but inflating to GBs in memory). It is possible to cause OOM to a 1k-user Gitlab instance with just 3 requests.
Steps to reproduce
- Register two VMs: a
1k-users self-hosted Gitlab EE instanceVM (8 vCPU, 16GB RAM) and anotherexternal_wiki_serversmaller VM. - Install latest Gitlab EE on ``1k-users self-hosted Gitlab EE instance``` VM.
- Create a new project.
- Upload these files ( and )to
external_wiki_serverVM - Start
external_wiki_serverat port 80:sudo nodejs wiki_server.js - Open 3 tabs with the same below URL. You can find equivalent curl command using Chrome's Developer Tools and send 3 requests by curl also. It would be the way to automate this attack for larger instances.
http://[your_GL's_host_name]/[optional_group_name]/[project_name]/-/settings/integrations/external_wiki/edit
- Fill in "External wiki URL" field of each tab with
http://[external_wiki_server_IP]/[anything]and click "Test settings" button - SSH into
1k-users self-hosted Gitlab instanceVM, run "htop" command. You should see that Gitlab consumes all available memory and the Gitlab instance becomes unavailable.
Impact
DOS: complete service outage to other users.
Examples
(If the bug is project related, please create an example project and export it using the project export feature)
(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)
(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.)
What is the current bug behavior?
Gitlab::HTTP gem doesn't validate "Content-Encoding" header of responses from external_wiki_server. A malicious server can send a zip-bomb as response body. Net/HTTP gem (the under-the-hood HTTP client of httparty and indirectly Gitlab::HTTP gem) decompresses the zip bomb automatically. This behavior could lead to uncontrolled resource (RAM) consumption.
What is the expected correct behavior?
Gitlab::HTTP gem should validate "Content-Encoding" header of responses from untrusted servers, deny all responses with a compressed format "Content-Encoding" header.
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.)
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info)
System information
System: Ubuntu 20.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 3.1.5p253
Gem Version: 3.5.11
Bundler Version:2.5.11
Rake Version: 13.0.6
Redis Version: 7.0.15
Sidekiq Version:7.1.6
Go Version: unknown
GitLab information
Version: 17.2.1-ee
Revision: 88793996279
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 14.11
URL: http://34.16.168.95
HTTP Clone URL: http://34.16.168.95/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.37.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.2.1
- default Git Version: 2.45.2
(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)
Impact
Attacker can take down a 1k-users Gitlab EE self-manage instance by testing a malicious external wiki URL in a project's settings. It would make the Gitlab EE instance unavailable to other users.
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
Root cause
Likely the Gitlab::HTTP gem does not validate the Content-Encoding header of responses from untrusted servers, and the underlying Net/HTTP client automatically decompresses compressed responses, leading to uncontrolled memory consumption.
Impact
An attacker could take down a 1k-user GitLab EE self-managed instance, making it unavailable to other users.
What the attacker needed
GitLab EE self-managed instance; Attacker controls external wiki server; Ability to create a project
The fix
Gitlab::HTTP gem should validate the Content-Encoding header of responses from untrusted servers and deny all responses with a compressed format Content-Encoding header.
How it was found
- Set up a GitLab EE instance and a separate server to host the malicious external wiki.
- Create a new project in GitLab.
- Upload the provided files to the external wiki server and start it on port 80.
- Open three tabs to the external wiki integration settings page for the project.
- In each tab, enter the external wiki URL pointing to the malicious server and click 'Test settings'.
- Observe that GitLab consumes all available memory and becomes unavailable.
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 add an external wiki link in GitLab, GitLab checks if the URL is valid by sending a request to that server. The server can reply with a tiny compressed file that expands to a huge size in memory. GitLab automatically decompresses it without checking, so the server's memory fills up and the whole GitLab instance crashes.
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.