Skip to content
DoS Disclosed report Intermediate

DOS via move_issue

Moving an issue with a specially crafted description causes high CPU usage for 60 seconds, leading to a request timeout. Multiple parallel requests can exhaust multiple CPUs and potentially make the entire server unavailable.

legit-security Follow

Originally disclosed on HackerOne

Bounty$2,300 Medium 6.5 View original
  • Triaged in 25 days
  • Fixed in 4 months
  • Paid in 31 days
  • Disclosed after 7 months

Summary by the researcher

We are Legit Security, a company building a solution that protects development environments and pipelines from security risks such as software supply-chain attacks and sensitive data exposure. You can read a bit about us at http://www.legitsecurity.com.

The report

Summary

Moving an issue with a specially-crafted description results in high CPU usage for 60 seconds (request timeout). Multiple requests can be issued in parallel to create a larger impact.

Steps to reproduce

  1. Given an authorized user (on GitLab.com - anyone can self-register. On EE - depends on instance configuration).
  2. Create an issue with the following description (provided a one-line python script to avoid bloating):
  3. Once created, move the issue to a different project.

The script:

python -c "print('![l' * 100000 + '\n')" Note: works with a lower number of repetitions too.

Impact

After 60 seconds (timeout) - the request fails. Meanwhile, on the server end, (a single) CPU is burnt out (verified against a local EE instance). Issuing multiple requests in parallel (on multiple GitLab issues) results in multiple CPUs burn out. Using the DockerHub image, the entire server is completely unavailable by repeatedly sending a small number of requests repeatedly.

Examples

The bug is instance-independent, works on latest versions. Since GitLab.com is open-core - it would work on GitLab too.

What is the current bug behavior?

The HTTP request fails for timeout while the server is burning CPU.

On the code side: lib/gitlab/gfm/uploads_rewriter.rb / module Gitlab/Gfm / class UploadsRewriter / function files: @text.scan(@pattern) Where FileUploader::MARKDOWN_PATTERN is assigned to the pattern data member.

MARKDOWN_PATTERN is: \!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\) The pattern is of a polynomial complexity, thus, the scan results in high CPU utilization.

What is the expected correct behavior?

Instead of using Ruby’s default Regex engine, use the RE2 engine (or the wrapped version at lib/gitlab/untrusted_regexp.rb), with the following pattern: \!?\[.*\]\(/uploads/([0-9a-f]{32})/(.*)\) As RE2 does not go beyond O(n), this scan becomes linear. Note: since RE2 does not support named captures, all references should be fixed - assigning the results to secret/identifier local variables.### Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Impact

A complete denial of service of a GitLab EE instance. As this vulnerability impacts GitLab.com, we assume that this vulnerability opens the door for a DDOS attack.

The original report as published on HackerOne, by legit-security. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

GitLab is a source code hosting and collaboration platform. One of its core features is the issue tracker: users create issues inside projects, and an issue can be moved from one project to another. Moving an issue means the platform has to rewrite references inside the issue text, including references to uploaded files, so that links keep pointing at the right place after the move.

The report targets the GitLab codebase at https://gitlab.com/gitlab-org/gitlab, and the researcher notes the bug is instance-independent and works on the latest versions. Because GitLab.com is open-core, the same behaviour would apply there too.

Setup

The preconditions are minimal:

  1. An authorised user. On GitLab.com anyone can self-register; on an EE instance it depends on the instance configuration.
  2. The ability to create an issue and to move it to a different project.

No special tooling is required. The researcher verified the server-side effect against a local EE instance and also describes behaviour using the DockerHub image.

Finding it

The researcher looked at what happens when an issue is moved. During the move, GitLab rewrites upload references in the issue description. The relevant code is in lib/gitlab/gfm/uploads_rewriter.rb, in module Gitlab::Gfm, class UploadsRewriter, function files, which runs:

Ruby
@text.scan(@pattern)

where the pattern data member is assigned FileUploader::MARKDOWN_PATTERN:

Text
\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)

That pattern has polynomial complexity, so scanning a description built to stress it results in high CPU utilisation. The description is attacker-controlled, which makes the scan input attacker-controlled as well.

Exploitation

Step 1: create an issue with a crafted description

With an authorised account, create an issue whose description is generated by the following one-line Python script, provided to avoid bloating the report:

Python
python -c "print('![l' * 100000 + '\n')"

The script prints the three-character sequence ![l repeated 100000 times, followed by a newline. The researcher notes that it works with a lower number of repetitions too. The repeated fragment is what drives the regex scan into its expensive path.

Step 2: move the issue to a different project

Once the issue exists, move it to a different project. The move triggers the uploads rewriter, which scans the crafted description with MARKDOWN_PATTERN.

Result

The HTTP request fails after 60 seconds (the request timeout). On the server side, a single CPU is burnt out for those 60 seconds; the researcher verified this against a local EE instance. Issuing multiple requests in parallel, on multiple GitLab issues, results in multiple CPUs burning out. Using the DockerHub image, the entire server becomes completely unavailable by repeatedly sending a small number of requests repeatedly.

Root cause

The uploads rewriter scans the issue text with Ruby's default regex engine using FileUploader::MARKDOWN_PATTERN. That pattern is of polynomial complexity, so the scan time grows disproportionately with crafted input, and the scan runs on attacker-controlled text during an issue move. The existing implementation therefore does not bound the work done per request.

The researcher's proposed correction is to stop using Ruby's default regex engine and use the RE2 engine instead, or the wrapped version at lib/gitlab/untrusted_regexp.rb, with this pattern:

Text
\!?\[.*\]\(/uploads/([0-9a-f]{32})/(.*)\)

Because RE2 does not go beyond O(n), the scan becomes linear. Since RE2 does not support named captures, all references would need to be fixed by assigning the results to secret/identifier local variables.

Impact

A complete denial of service of a GitLab EE instance. The request itself fails at the 60-second timeout while the server burns CPU, and parallel requests against multiple issues multiply the effect across CPUs. As the vulnerability impacts GitLab.com, the researcher assumes it opens the door for a DDoS attack.

Fix

The report recommends replacing the default Ruby regex engine with RE2, or the wrapper at lib/gitlab/untrusted_regexp.rb, and rewriting the pattern as shown above, adjusting the code for the loss of named captures. The report does not describe a fix that was actually shipped.

Variants to test

  • A positive result is a request that runs until the timeout while a server CPU stays saturated.
  • A positive result is scan time that grows disproportionately as the input length increases.
  • The researcher notes the effect works with a lower number of repetitions too.

Hunting notes

This kind of bug hides in server-side processing of user-controlled text: Markdown rewriting, link rewriting, reference extraction and any place where a regex with nested quantifiers runs over content the user supplies. The researcher verified the CPU burn on a local EE instance, described parallel requests multiplying the effect, and described full unavailability with the DockerHub image.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

GitLab is a website where teams keep their source code and work on it together. One of its everyday features is the issue tracker: inside a project you can open an "issue", which is basically a written note describing a task, a bug or a request. An issue has a title and a description, and the description can contain text plus links to files you uploaded.

Issues can also be moved from one project to another. When you move an issue, GitLab has to go through the text and update the links to uploaded files, so that after the move they still point at the right place. To do that, the server reads the description and looks for patterns that look like file links.

The researcher found that if you write a description in a very particular, repetitive shape, that search takes an enormous amount of computing time. The server keeps working on it until the request times out after 60 seconds, and during those 60 seconds one processor core of the server is fully busy. Send several of these moves at the same time and you keep several cores busy. Do it repeatedly against a small server and the whole server becomes unavailable to everyone. That is a denial of service: you are not stealing data or breaking in, you are making the service stop working for other people.

The report targets the GitLab codebase at https://gitlab.com/gitlab-org/gitlab. The researcher says the bug does not depend on a particular installation and works on the latest versions. GitLab.com runs the same core software, so the same behaviour applies there.

Setup

You need very little to try this:

  1. An authorised user account. On GitLab.com anyone can sign up by themselves; on a self-hosted EE instance it depends on how that instance is configured.
  2. The ability to create an issue and to move it to a different project.

No special tools are needed. The researcher checked the effect on the server against a local EE instance and also describes what happens with the DockerHub image (a ready-made copy of GitLab you can run on your own machine).

Finding it

A quick word on the concepts involved, because the rest of the report leans on them.

A regular expression (often shortened to "regex") is a small pattern language for finding text. You write something like "a bracket, then any characters, then a closing bracket" and the computer searches a piece of text for anything matching that shape. It is the same idea as the search box in a text editor, but far more precise.

Some regex patterns are cheap to run and some are expensive. A pattern with repeated "any characters" pieces can, on the wrong input, force the computer to try a huge number of combinations before giving up. The time needed then grows much faster than the length of the text. People call this "polynomial complexity", or sometimes "catastrophic backtracking". A simple comparison: asking someone to find a word in a page is quick; asking them to try every possible grouping of the letters on that page is not, and the work explodes as the page gets longer.

The researcher looked at what happens when an issue is moved. During the move, GitLab rewrites upload references in the issue description. The relevant code is in lib/gitlab/gfm/uploads_rewriter.rb, in module Gitlab::Gfm, class UploadsRewriter, function files, which runs:

Ruby
@text.scan(@pattern)

Line by line:

  • @text is the issue description, the text the user wrote.
  • .scan(...) is a Ruby method that walks through that text and collects every piece that matches a pattern.
  • @pattern is the pattern to look for, stored on the object.

That pattern is assigned FileUploader::MARKDOWN_PATTERN, which is:

Text
\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)

Reading it piece by piece:

  • \!? means an optional exclamation mark.
  • \[ means a literal opening square bracket [.
  • .*? means "any characters, as few as possible".
  • \] means a literal closing square bracket ].
  • \( means a literal opening round bracket (.
  • /uploads/ is literal text, the folder where uploaded files live.
  • (?<secret>[0-9a-f]{32}) captures a 32-character identifier made of digits and the letters a to f, and names that piece secret.
  • / is a literal slash.
  • (?<file>.*?) captures the file name, again "any characters, as few as possible", and names it file.
  • \) means a literal closing round bracket ).

In short: the pattern is meant to recognise Markdown image links that point at uploaded files. The problem is the combination of the "any characters, as few as possible" pieces with the surrounding brackets. On text built to stress it, the regex engine has to try a very large number of ways of splitting the text before it can decide there is no match. That is the polynomial complexity mentioned above, and it is why the scan burns CPU. The description is written by the attacker, so the input to that scan is fully under the attacker's control.

Exploitation

Step 1: create an issue with a crafted description

With an authorised account, create an issue whose description is generated by the following one-line Python script. The researcher provided the script so the report would not be bloated by a gigantic block of text:

Python
python -c "print('![l' * 100000 + '\n')"

Line by line:

  • python -c "..." runs a short Python program given directly on the command line, without saving it to a file.
  • print(...) prints something to the screen.
  • '![l' * 100000 takes the three characters !, [ and l and repeats them 100000 times. In Python, multiplying a piece of text by a number repeats it.
  • + '\n' adds a newline character at the end.

The result is a very long line made of the same small fragment over and over. The researcher notes that it works with a lower number of repetitions too. The repeated fragment is what drives the regex scan into its expensive path.

Step 2: move the issue to a different project

Once the issue exists, move it to a different project. The move triggers the uploads rewriter, which scans the crafted description with MARKDOWN_PATTERN.

Result

The HTTP request fails after 60 seconds, which is the request timeout. On the server side, a single CPU is fully busy for those 60 seconds; the researcher verified this against a local EE instance. Issuing multiple requests in parallel, on multiple GitLab issues, results in multiple CPUs burning out. Using the DockerHub image, the entire server becomes completely unavailable by repeatedly sending a small number of requests repeatedly.

Root cause

The uploads rewriter scans the issue text with Ruby's default regex engine using FileUploader::MARKDOWN_PATTERN. That pattern is of polynomial complexity, so the scan time grows disproportionately with crafted input, and the scan runs on attacker-controlled text during an issue move. The existing implementation therefore does not bound the work done per request.

The researcher's proposed correction is to stop using Ruby's default regex engine and use the RE2 engine instead, or the wrapped version at lib/gitlab/untrusted_regexp.rb, with this pattern:

Text
\!?\[.*\]\(/uploads/([0-9a-f]{32})/(.*)\)

What changed, in plain words:

  • The two .*? pieces became .*, and the named captures became plain groups.
  • The named captures (?<secret>...) and (?<file>...) became plain groups (...), because RE2 does not support named captures.

RE2 is a different regex engine, designed so that its running time never grows faster than linearly with the length of the text. In other words, doubling the text roughly doubles the work, instead of multiplying it many times over. That is what makes the scan safe here. Since RE2 does not support named captures, all references would need to be fixed by assigning the results to secret/identifier local variables.

Impact

A complete denial of service of a GitLab EE instance. The request itself fails at the 60-second timeout while the server burns CPU, and parallel requests against multiple issues multiply the effect across CPUs. As the vulnerability impacts GitLab.com, the researcher assumes it opens the door for a DDoS attack. A DDoS, or distributed denial of service, is when many requests are sent at once, often from many places, so that a service cannot keep up and stops answering normal users.

Fix

The report recommends replacing the default Ruby regex engine with RE2, or the wrapper at lib/gitlab/untrusted_regexp.rb, and rewriting the pattern as shown above, adjusting the code for the loss of named captures. The report does not describe a fix that was actually shipped.

Variants to test

  • A positive result is a request that runs until the timeout while a server CPU stays saturated.
  • A positive result is scan time that grows disproportionately as the input length increases.
  • The researcher notes the effect works with a lower number of repetitions too.

Hunting notes

This kind of bug hides in server-side processing of user-controlled text: Markdown rewriting, link rewriting, reference extraction and any place where a regex with nested quantifiers runs over content the user supplies. The researcher verified the CPU burn on a local EE instance, described parallel requests multiplying the effect, and described full unavailability with the DockerHub image.

Glossary

  • API: a way for one program to talk to another over the network, using agreed requests and responses.
  • Authorised user: an account that is allowed to log in and use the features of the site.
  • CPU: the processor inside a computer that does the actual calculating. "Burning CPU" means it is kept fully busy.
  • Cross-project reference: a link in one project that points at something in another project.
  • DDoS (distributed denial of service): flooding a service with requests, often from many sources, until it can no longer serve normal users.
  • Denial of service (DoS): making a service unavailable to the people who should be able to use it, without necessarily breaking into it.
  • DockerHub image: a ready-made packaged copy of software that you can download and run on your own machine or server.
  • EE instance: a self-hosted installation of GitLab Enterprise Edition, the commercial edition of GitLab.
  • GitLab.com: the public hosted version of GitLab, run by GitLab itself.
  • HTTP request: the message a browser sends to a website to ask for a page or to submit an action.
  • Issue: a written note inside a project describing a task, bug or request, with a title and a description.
  • Linear complexity: work that grows in proportion to the size of the input; twice the text means roughly twice the work.
  • Markdown: a simple way of writing formatted text using plain characters, for example ![alt](link) for an image.
  • Named capture: a way in a regex to give a matched piece of text a name so the code can refer to it later.
  • Open-core: a software model where a free core product is published openly and extra features are sold separately.
  • Polynomial complexity: work that grows much faster than the size of the input, so a longer text can take disproportionately longer to process.
  • Quantifier: in a regex, a symbol that says how many times something may repeat, such as * for "any number of times".
  • RE2: a regex engine built so that its running time never grows faster than linearly with the input.
  • Regex (regular expression): a small pattern language for finding text that matches a certain shape.
  • Request timeout: a limit on how long a request may take before the server gives up and returns an error.
  • Ruby: the programming language GitLab is written in.
  • Scan: walking through a piece of text and collecting every part that matches a pattern.
  • Self-register: creating your own account on a site without needing an administrator to set it up for you.
  • Upload reference: a link in text that points at a file someone uploaded.
  • Uploads rewriter: the part of GitLab that updates upload links in text, for example when an issue is moved.

More by legit-security

View all

2 more disclosed reports, best first.

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.