CVE-2023-26115 is a severe vulnerability affecting all versions of the popular open-source package 'word-wrap.' This package is widely used for wrapping lines of text to fit within a specified column width. The package's fundamental flaw resides in its regular expression usage, which leads to Regular Expression Denial of Service (ReDoS) attacks. This post will explain the vulnerability, provide code snippets illustrating the issue, and list relevant resources.

Vulnerability Details

The vulnerability in the 'word-wrap' package is tied to the insecure regular expression employed within the 'result' variable. The regular expression has an exponential worst-case performance, meaning an attacker can leverage it to create ReDoS attacks. ReDoS exploits are a type of DoS attack that targets the performance of regular expressions, potentially crippling the application or server being targeted.

Code Snippet

The code snippet below shows a sample usage of the 'word-wrap' package, along with the vulnerable regular expression used within the 'result' variable:

const wrap = require('word-wrap');

const options = {
  width: 80,
  newline: '\n',
  indent: ''

const inputText = 'This is a sample text that will be word-wrapped using the vulnerable package. The vulnerable regex used within the result variable can lead to ReDoS attacks.';

const result = wrap(inputText, options);


The vulnerable regular expression used within the 'result' variable can be found in the package's source code:

const re = /(\S+\s*)/g;

Exploit Details

An attacker exploiting CVE-2023-26115 can take advantage of the package's insecure regex to create long input strings that significantly slow down or halt the application's performance. The crafted input forces the application to match an excessive number of regular expression patterns, resulting in a ReDoS attack. Due to this vulnerability, web applications and servers running the affected versions of this package are highly susceptible to devastating DoS attacks.

1. CVE-2023-26115 Advisory on NVD
2. 'word-wrap' package on npm
3. OWASP Article on ReDoS
4. ReDoS Explained - Cloudflare Learning Center


In conclusion, CVE-2023-26115 is a critical vulnerability in all versions of the 'word-wrap' package, which puts applications and servers utilizing this package at risk of crippling ReDoS attacks. The community is encouraged to raise awareness of this vulnerability and patch the affected package as soon as possible. Developers should also be cautious when implementing regular expressions to avoid creating similar vulnerabilities in the future.


Published on: 06/22/2023 05:15:00 UTC
Last modified on: 08/24/2023 16:15:00 UTC