CVE-2017-16116: Regular Expression Denial of Service in string

string Updated 02 Oct 2025

Summary

24/07/2018
No i
High
7.5

CVE-2017-16116: Regular Expression Denial of Service in string package. Affects string versions < 3.3.3. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The string package is an npm package that provides various string manipulation functions. It is commonly used in JavaScript projects to simplify string operations. The package includes methods such as underscore and unescapeHTML which are vulnerable to regular expression denial of service (ReDoS) attacks when untrusted user input is passed into them.

Vulnerability Detail

The vulnerability in the string package allows an attacker to perform a ReDoS attack by providing specially crafted input to the underscore or unescapeHTML methods. This can lead to a denial of service situation where the application becomes unresponsive or crashes. The vulnerability affects versions 0.0.0 to 3.3.3 of the string package.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

To mitigate the vulnerability, it is recommended to implement input validation and sanitization before using the underscore and unescapeHTML methods. This can be done by using regular expressions with a timeout or by limiting the complexity of the input. Here is an example of input validation using a regular expression with a timeout:

const string = require('string');

function validateInput(input) {
  const regex = /^([a-zA-Z0-9]+)$/;
  const timeout = 1000; // Set a timeout of 1 second

  try {
    regex.test(input);
  } catch (error) {
    if (error instanceof Error && error.message.includes('potential ReDoS')) {
      throw new Error('Input validation failed: Potential ReDoS attack detected.');
    }
  }
}

Conclusion

The string package is vulnerable to regular expression denial of service attacks when untrusted user input is passed into the underscore or unescapeHTML methods. To mitigate the vulnerability, it is important to validate and sanitize user input before using these methods. Currently, there is no direct patch available, but implementing input validation and following best practices can help protect against this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for string →

Share this vulnerability

FAQ

The vulnerability allows an attacker to perform a ReDoS attack, which can lead to a denial of service situation where the application becomes unresponsive or crashes.

Versions 0.0.0 to 3.3.3 of the string package are affected.

Currently, there is no direct patch available for this vulnerability. The best solution is to avoid passing user input to the vulnerable methods.

Yes, implementing input validation and sanitization before using the vulnerable methods can help mitigate the vulnerability. It is recommended to use regular expressions with a timeout or limit the complexity of the input.

The user-provided patch in Pull Request #217 is available, but it has not been tested or merged by the package author. It is recommended to use caution when considering this patch.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback