DOS due to nested markdown link
The server cannot handle nested markdown links, causing high memory and CPU usage when rendering markdown via the API or web interface. An attacker with low bandwidth and no privileges can make the server unresponsive.
GitLab
Originally disclosed on GitLab
- Fixed in 11 days
- Disclosed after 11 days
HackerOne report #916128 by grinner on 2020-07-05, assigned to @rchan-gitlab:
Summary
Server is not able to handle nested markdown link and leads to high memory usage both via API and the web application.
Steps to reproduce
Steps1: (API)
- Put the files exp and exploit.py in the same folder
2.Edit (URL) and run the exploit python3 exploit.py (might need to install requests module)
-
Observe we are getting a huge amount of RAM usage for relatively small amounts of data being sent.
-
The gitlab instance/server will stop responding.
Steps2: (Web)
- Create or Upload an .md file in a repository with the contents of
expfile. - View the page that renders the markdown content. (preferably readme.md so that it loads by default for all users visiting the repo)
- Opening multiple tabs with the same content hogs server memory.
I guess there are alot more locations this might be exploitable. eg: issues (multiple comments (use smallexp) ), docs, wiki etc basically anywhere markdown is rendered.
Impact
API:
At attacker with low bandwith and no privilage make the server unaccesable.
Note: no account/key needed is to hit /api/v4/markdown endpoint used in exploit.py
Web:
This leads to both unresponsive UI and unreponsive (overloaded) server. At attacker with low bandwith and low/no privilage can do it.
Examples
Did in local VM environment. If you provide a safe test server to try this against I can show it there too. (The instructions provided should be enough for you to replicate)
Screenshots:
1.png the markdown in repository
2.png the markdown in a issue comment (the websitebrowser crashes also the gitlab server gets very loaded)
vid.gif contains a small exploit video. (same as steps 1)
What is the current bug behavior?
Server is unable to properly handle the nested markdown which leads to high CPU and RAM usage. This is exploitable both via API and also when markdown is rendered in UI.
What is the expected correct behavior?
Server should handle the nested markdown and reject/satanized them
Relevant logs and/or screenshots
NA (see screenshots above)
Output of checks
NA
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: LinuxMint 19.1
Current User: git
Using RVM: no
Ruby Version: 2.6.6p146
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.7
Git Version: 2.26.2
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.10.13
Revision: 5c8f65cde30
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 11.7
URL: http://192.168.56.102
HTTP Clone URL: http://192.168.56.102/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 12.2.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Impact
An attacker can cause a denial of service and make the server inaccessible to normal/legitimate users.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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 markdown parser does not limit recursion or resource usage when processing deeply nested links, leading to excessive memory and CPU consumption.
Impact
An attacker with low bandwidth and no privileges can cause a denial of service, making the server inaccessible to legitimate users.
What the attacker needed
No account needed for API; low bandwidth; victim views markdown (web)
The fix
The server should handle nested markdown and reject or sanitize them.
How it was found
- Place the exploit files in the same folder and run the Python script against the API endpoint.
- Observe high RAM usage from relatively small data.
- The GitLab instance stops responding.
- Alternatively, upload a markdown file with nested links to a repository and view it.
- Opening multiple tabs with the same content increases server memory usage.
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.
Markdown is a simple way to format text, and links can be nested inside each other. The server tries to process these nested links but uses too much memory and processing power, so it slows down or stops working for everyone. An attacker can send a small amount of data to cause this, without needing an account.
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.