npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@makenowjust-labo/recheck

v3.1.0

Published

A vulnerable RegExp (ReDoS) checker for JavaScript (ECMA-262) RegExp.

Downloads

2,196

Readme

@makenowjust-labo/recheck

A vulnerable RegExp (ReDoS) checker for JavaScript (ECMA-262) RegExp.

Installation

Uses the following command to install this library:

$ npm install @makenowjust-labo/recheck

Usage

This library exports only the API called check. It takes a RegExp pattern source and flags to be checked (and a configuration optionally), then it returns the analysis result.

const { check } = require("@makenowjust-labo/recheck");

console.log(check("^(a|a)*$", ""));
// {
//   status: 'vulnerable',
//   checker: 'automaton',
//   attack: {
//     pumps: [ { prefix: 'a', pump: 'a', bias: 0 } ],
//     suffix: '\x00',
//     base: 17,
//     string: 'aaaaaaaaaaaaaaaaaa\x00',
//     pattern: "'a' 'a'¹⁷ '\\x00'"
//   },
//   complexity: { type: 'exponential', summary: 'exponential', isFuzz: false }
// }

Configuration

A configuration parameter specifies as the 3rd argument of the check function.

console.log(check("^(a|a)*$", "", { timeout: 1000, checker: "fuzz" }));

The following parameters are available.

timeout

An integer value of timeout duration milliseconds. (default: undefined)

When undefined is specified, it means there is no timeout.

checker

A checker name to use. (default: 'hybrid')

There are three checkers:

  • 'automaton': A checker which works based on automaton theory. It can analyze a ReDoS vulnerability of the RegExp without false positives, however, it needs some minutes against some RegExps and it does not support some syntax.
  • 'fuzz': A checker based on fuzzing. It can detect a ReDoS vulnerability against all RegExp syntax including back-references and look-around assertions. However, it needs some seconds on average and it may cause false negatives.
  • 'hybrid': A checker which combines the automaton based checker and the fuzz checker. If the RegExp is supported by the automaton based checker and some thresholds are passed, it uses the automaton based checker. Otherwise, it falls back to the fuzz checker.

The hybrid checker performs better than others in many cases.

And, there are other parameters to specify detailed behavior. They are set to perform better as the default, so it is rare to specify them and it needs to know the checkers in depth to set the correct value.

maxAttackSize

An integer value of a maximum length of an attack string. (default: 4_000)

The checker finds a vulnerable string not to exceed this length.

attackLimit

An integer value of a limit of VM execution steps. (default: 100_000)

The checker assumes the RegExp is vulnerable when a string exists against which steps exceed the limit.

randomSeed

An integer value of seed for pseudo-random number generator in fuzzing. (default: undefined)

When undefined is specified, it uses a system default seed.

seedLimit

An integer value of a limit of VM execution steps on the seeding phase. (default: 1_000)

incubationLimit

An integer value of a limit of VM execution steps on the incubation phase. (default: 10_000)

crossSize

An integer value of the number of crossings on one generation. (default: 25)

mutateSize

An integer value of the number of mutations on one generation. (default: 50)

maxSeedSize

An integer value of a maximum size of a seed set. (default: 50)

maxGenerationSize

An integer value of a maximum size of a living population on one generation. (default: 100)

maxIteration

An integer value of a number of iterations on the incubation phase. (default: 30)

maxDegree

An integer value of a maximum degree to attempt on building an attack string. (default: 4)

heatRate

A rate of a hotspot steps by the maximum steps. (default: 0.001)

usesAcceleration

Whether to use acceleration or not on fuzzing. (default: true)

maxRepeatCount

An integer value of a limit of repetition count in the RegExp. (default: 20)

If the RegExp exceeds this limit on the hybrid checker, it switches to use the fuzz checker to analyze instead of the automaton based checker.

maxNFASize

An integer value of a maximum size of the transition function of NFA. (default: 40000)

If the NFA's transition function exceeds this limit on the hybrid checker, it switches to use fuzz checker to analyze instead of the automaton based checker.

maxPatternSize

An integer value of maximum size of the pattern. (default: 1500)

If the pattern size exceeds this limit on the hybrid checker, it switches to use fuzz checker to analyze instead of the automaton based checker.

License

MIT License.

2020-2021 (C) TSUYUSATO "MakeNowJust" Kitsune