Skip to content
DoS Disclosed report Intermediate

ReDoS in markup page

Markup pages ending in .wiki or .mediawiki are vulnerable to regular expression denial of service because a regex used to remove comments can be made to run for a very long time. An attacker could create multiple such files to cause a denial of service on the GitLab server.

GitLab

Originally disclosed on GitLab

  • Fixed in 6 months
  • Disclosed after 6 months

HackerOne report #1213328 by yvvdwf on 2021-05-31, assigned to @dcouture:

Report | How To Reproduce

Report

Markup pages ending by .wiki or .mediawiki are vulnerable to Regular expression Denial of Service.

Steps to reproduce
  1. In an existing project or create a new one, then add a new file ending by .wiki, such as, redos.wiki with the following content:
==<!--                                                                                                                           ==  
  1. Save, then view the file on gitlab in "Display rendered file" mode that is by default when viewing a markup file.
  2. The CPU server is 100% performance
Impact

By creating multiple redos files may cause dos on the gitlab server.

What is the current bug behavior?

A regex in WikiCloth that is used to remove comments is vulnerable to redos:

Ruby
data.gsub!(/<!--(.|\s)*?-->/,""  
Output of checks

I've tested on my own instance of gitlab

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 18.04  
Proxy:		no  
Current User:	git  
Using RVM:	no  
Ruby Version:	2.7.2p137  
Gem Version:	3.1.4  
Bundler Version:2.1.4  
Rake Version:	13.0.3  
Redis Version:	6.0.10  
Git Version:	2.29.0  
Sidekiq Version:5.2.9  
Go Version:	go1.10.4 linux/amd64

GitLab information  
Version:	13.10.3-ee  
Revision:	db2e358dba4  
Directory:	/opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:	PostgreSQL  
DB Version:	12.6  
URL:		http://gl.local  
HTTP Clone URL:	http://gl.local/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:	13.17.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

Cause deny of service at the server side

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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 regex used to strip HTML comments uses a lazy quantifier with alternation that causes catastrophic backtracking on long unterminated comments.

Impact

By creating multiple such files, an attacker could cause a denial of service on the GitLab server.

What the attacker needed

Ability to create or edit a project file

How it was found

  1. Create or use an existing project and add a new file ending in .wiki with a long unterminated comment.
  2. Save the file and view it in 'Display rendered file' mode.
  3. Observe that the server CPU reaches 100%.

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 regular expression is a pattern used to search text. Some patterns can take a very long time on certain inputs, which is called a regular expression denial of service (ReDoS). Here, a file with a specially crafted comment makes the server's CPU work at 100%, so the server becomes slow or unavailable.

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.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.