Skip to content

@octokit/request-error has a Regular Expression in index that Leads to ReDoS Vulnerability Due to Catastrophic Backtracking

Moderate severity GitHub Reviewed Published Feb 14, 2025 in octokit/request-error.js • Updated Feb 14, 2025

Package

npm @octokit/request-error (npm)

Affected versions

>= 1.0.0, < 5.1.1
>= 6.0.0, < 6.1.7

Patched versions

5.1.1
6.1.7

Description

Summary

A Regular Expression Denial of Service (ReDoS) vulnerability exists in the processing of HTTP request headers. By sending an authorization header containing an excessively long sequence of spaces followed by a newline and "@", an attacker can exploit inefficient regular expression processing, leading to excessive resource consumption. This can significantly degrade server performance or cause a denial-of-service (DoS) condition, impacting availability.

Details

The issue occurs at line 52 of iterator.ts in the @octokit/request-error repository.
The vulnerability is caused by the use of an inefficient regular expression in the handling of the authorization header within the request processing logic:

authorization: options.request.headers.authorization.replace(
  / .*$/, 
  " [REDACTED]"
)

The regular expression / .*$/ matches a space followed by any number of characters until the end of the line. This pattern is vulnerable to Regular Expression Denial of Service (ReDoS) when processing specially crafted input. Specifically, an attacker can send an authorization header containing a long sequence of spaces followed by a newline and "@", such as:

headers: {
  authorization: "" + " ".repeat(100000) + "\n@",
}

Due to the way JavaScript's regular expression engine backtracks while attempting to match the space followed by arbitrary characters, this input can cause excessive CPU usage, significantly slowing down or even freezing the server. This leads to a denial-of-service condition, impacting availability.

PoC

The gist of PoC.js

  1. run npm i @octokit/request-error
  2. run 'node poc.js'
    result:
  3. then the program will stuck forever with high CPU usage
import { RequestError } from "@octokit/request-error";

const error = new RequestError("Oops", 500, {
  request: {
    method: "POST",
    url: "https://api.github.com/foo",
    body: {
      bar: "baz",
    },
    headers: {
      authorization: ""+" ".repeat(100000)+"\n@",
    },
  },
  response: {
    status: 500,
    url: "https://api.github.com/foo",
    headers: {
      "x-github-request-id": "1:2:3:4",
    },
    data: {
      foo: "bar",
    },
  },
});

Impact

Vulnerability Type & Impact:

This is a Regular Expression Denial of Service (ReDoS) vulnerability, which occurs due to an inefficient regular expression (/ .*$/) used to sanitize the authorization header. An attacker can craft a malicious input that triggers excessive backtracking in the regex engine, leading to high CPU consumption and potential denial-of-service (DoS).

Who is Impacted?

  • Projects or services using this code to process HTTP headers are vulnerable.
  • Applications that rely on user-supplied authorization headers are at risk, especially those processing a large volume of authentication requests.
  • Multi-tenant or API-driven platforms could experience degraded performance or service outages if exploited at scale.

References

@nickfloyd nickfloyd published to octokit/request-error.js Feb 14, 2025
Published to the GitHub Advisory Database Feb 14, 2025
Reviewed Feb 14, 2025
Published by the National Vulnerability Database Feb 14, 2025
Last updated Feb 14, 2025

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

EPSS score

Weaknesses

CVE ID

CVE-2025-25289

GHSA ID

GHSA-xx4v-prfh-6cgc

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.