Skip to content

Potential Regular Expression Denial of Service (ReDoS) in valid-var-jsdoc #362

Description

@yetingli

Type of Issue
Potential Regular Expression Denial of Service (ReDoS)

Description
The vulnerable regular expressions are located in

var CONST_PATTERN = /^[A-Z]([A-Z\d$]+_?)*[A-Z\d$]$/;

var PASCAL_PATTERN = /^([A-Z][a-zA-Z\d$]+)+$/;

The ReDOS vulnerabilities can be exploited with the following string
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_

You can execute the following code to reproduce ReDos

var rule = require('../../../../lib/js/rules/valid-var-jsdoc');
var RuleTester = require('eslint').RuleTester;

var ruleTester = new RuleTester({parser: 'babel-eslint'});

ruleTester.run('valid-var-jsdoc', rule, {
    invalid: [
        'var AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_ = 1;',
        'const AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_ = 1;',
    ],
});

I think you can limit the input length or modify this regex.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions