Skip to content

ReDoS Vulnerability in shellwords #13

@cyxxuan

Description

@cyxxuan

Vulnerability type

RegExp Denial-of-Service——catastrophic backtracking in regex evaluation

Vulnerability Location

In the split function of [email protected], the following regular expression is used:

/\s*(?:([^\s\\'"]+)|'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/

Description

The split function in shellwords uses a complex regular expression to tokenize shell-like input strings.
However, this regex is vulnerable to catastrophic backtracking, which can cause CPU exhaustion and application hang when processing specially crafted input.

Proof of Concept (PoC)

require("shellwords").split('\n' + ' '.repeat(100000))

Affected version

[email protected]
(Other versions using the same regex implementation may also be affected)

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