Skip to content
DoS Disclosed report Intermediate

ReDoS in message formater using Slack notifications integration that can fully occupy Sidekiq utilization

A regular expression used to format relative links in issue descriptions has polynomial complexity, allowing an attacker to cause a denial of service by submitting a specially crafted string. When Slack integration is enabled, this regex runs in Sidekiq background jobs, and by creating multiple issues with the malicious string, the attacker can block all Sidekiq threads, preventing other background jobs from running.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 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 #2428902 by joaxcar on 2024-03-21, assigned to @cmaxim:

Report | Attachments | How To Reproduce

Report

Summary

Hi team! I think this is my last ReDoS issue :) when I first found this one, I did not understand the impact, but after learning more about Sidekiq, I now see that this one also has the potential for high availability impact.

An attacker can configure Slack notifications as an integration. This is done by providing an incoming webhook to a Slack app. When a new issue is created, a message will be sent to the Slack app, and it will be posted in the designated Slack channel.

When GitLab is preparing the issue description to be sent to Slack this code will run

Ruby
RELATIVE_LINK_REGEX = %r{!\[[^\]]*\]\((/uploads/[^\)]*)\)}  
...  
def format_relative_links(string)  
        string.gsub(RELATIVE_LINK_REGEX, "#{project_url}\\1")  
end  

Which tries to extract markdown image links ![](). This RELATIVE_LINK_REGEX is subject to polynomial complexity when evaluated against a long string of this format

JavaScript
"{{media:0}}

{{media:1}}

The 20 Blocking jobs should be your Integration jobs. The request queue should eventually just grow as the jobs are blocking all 20 threads.

####  Impact

ReDoS issue allows to block all threads in Sidekiq which will block all other background jobs to run

####  What is the current *bug* behavior?

The `RELATIVE_LINK_REGEX` regexp is subject to polynomial runtime

####  What is the expected *correct* behavior?

The regexp should be restricted in size or have other limits

####  Output of checks

#####  Results of GitLab environment info

System information
System: Debian 12
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 3.1.4p223
Gem Version: 3.5.5
Bundler Version:2.5.5
Rake Version: 13.0.6
Redis Version: 7.0.15
Sidekiq Version:7.1.6
Go Version: unknown

GitLab information
Version: 16.9.2-ee
Revision: 0d71d32d321
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 14.10
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version: 14.33.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: 16.9.2
  • default Git Version: 2.43.0

####  Impact

ReDoS issue allows to block all threads in Sidekiq which will block all other background jobs to run

## Attachments

**Warning:** Attachments received through HackerOne, please exercise caution!

* [blocked1.png](https://h1.sec.gitlab.net/a/f9c0e945-b5bb-428a-891a-0be796d6fb68/blocked1.png)
* [blocked2.png](https://h1.sec.gitlab.net/a/41d8164a-3918-4a7f-9733-520582179b1e/blocked2.png)

## How To Reproduce

Please add [reproducibility information] to this section:

1.
1.
1.

[reproducibility information]: https://about.gitlab.com/handbook/engineering/security/#reproducibility-on-security-issues

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 RELATIVE_LINK_REGEX regular expression has polynomial time complexity on crafted input.

Impact

An attacker could block all Sidekiq threads, preventing other background jobs from running, which may degrade the availability of the GitLab instance.

What the attacker needed

Attacker has a GitLab account; Slack integration is configured; Attacker can create issues

The fix

The regular expression should be restricted in size or have other limits to prevent excessive backtracking.

How it was found

  1. Log in as the attacker and create a new project.
  2. Configure Slack integration with any webhook URL.
  3. Create a new issue with a name and a description containing a long string of repeated '![' characters.
  4. Capture the issue creation request as a fetch command using browser developer tools.
  5. Replay the request at least 20 times to create multiple issues.
  6. Log in as admin and check the background jobs page to see blocked jobs.

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 or manipulate text. Some regex patterns can become very slow when given certain inputs, especially long strings with repeated characters. Here, a regex that looks for image links in issue descriptions can take a very long time to process if the description contains many repeated '![' sequences. This slowness happens in background jobs that send Slack notifications, and because there are limited worker threads, an attacker can tie them all up, stopping other important background tasks like sending emails or creating pipelines.

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.