Skip to content
DoS Disclosed report Intermediate

ReDoS issue in the Codeowners reference extractor

A regular expression used to extract email addresses from CODEOWNERS files is vulnerable to catastrophic backtracking (ReDoS). An attacker could send a small number of requests to the validateCodeownerFile GraphQL query with a long string ending in '@', causing high CPU usage and delays for other users.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 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 #2269023 by joaxcar on 2023-12-01, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

There exists a ReDoS issue in the Codeowners reference extractor
https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/gitlab/code_owners/reference_extractor.rb#L11

The Regex looks like this.

      EMAIL_REGEXP = /(?<email>([^@\s]+@[^@\s]+(?<!\W)))/  

and will time out on long strings ending with an @ character

Screenshot_2023-12-01_at_14.25.22.png
Screenshot_2023-12-01_at_14.25.22.png From the original on GitLab
Screenshot_2023-12-01_at_14.26.05.png
Screenshot_2023-12-01_at_14.26.05.png

By sending a small number of requests to the validateCodeownerFile graphQL query, the instance will start running all CPUs on 100% and cause delays on user requests to the server.

Steps to reproduce

Test this on a self-hosted instance! use a Premium instance

  1. Log in to https://gitlab.example.com
  2. Create a new new project
  3. In the project create a file named CODEOWNERS
  4. Add this content in the file
README.md <ZEROS>@  

Replace <ZEROS>with A LOT of zeros. Dont know what is the lower threshold but add like 100 000 to be sure.
5. Save the file
6. Open devtools
7. Refresh the page
8. Go to the network tab. You should see a graphql request in pending state.
9. Right click the request and select copy and copy as curl
10. Use it in a terminal like this

Bash
for i in $(seq 1 20);  
do  
<CURL COMMAND> &  
done  
  1. Open top or htop on the gitlab server to see all CPUs going to 100%. Also, try to use the site and see that you get a lot of delays.

The DOS is only up for 1 min, and then the attacker needs to send requests again. But the number of requests is low

Impact

ReDoS takes up CPU and causes resource consumption by a low amount of requests. Can keep an instance inaccessible with about 10 requests a minute.

What is the current bug behavior?

The regexp used to check for email addresses in CODEOWNERS is vulnerable to REDOS

What is the expected correct behavior?

The regexp needs to be rewritten to avoid locking up the Puma threads

Impact

ReDoS takes up CPU and causes resource consumption by a low amount of requests. Can keep an instance inaccessible with about 10 requests a minute.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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

The email validation regex is vulnerable to ReDoS, timing out on long strings ending with '@'.

Impact

A low number of requests (about 10 per minute) could keep an instance inaccessible by consuming CPU resources.

What the attacker needed

Self-hosted GitLab Premium instance; authenticated user

The fix

The regular expression should be rewritten to avoid catastrophic backtracking and prevent locking up Puma threads.

How it was found

  1. Log in to a self-hosted GitLab instance (Premium).
  2. Create a new project.
  3. Create a file named CODEOWNERS.
  4. Add content consisting of 'README.md', many zeros, and '@'.
  5. Save the file and refresh the page.
  6. In devtools, copy the pending GraphQL request as curl and run it repeatedly (e.g., 20 times) to observe CPU 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 regular expression (regex) is a pattern used to search text. Some patterns can take a very long time to process certain inputs, especially long strings with repeated characters. Here, a crafted CODEOWNERS file with many zeros followed by '@' makes the regex backtrack excessively, using up CPU and slowing down the server for everyone.

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.