Skip to content

Parsing [\\\\\\… takes exponential time #157

@andersk

Description

@andersk

new commonmark.Parser().parse("[" + "\\".repeat(n)) runs in exponential time:

[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 1.2 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 1.8 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 2.9 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 4.7 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 7.5 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 12.5 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 20.2 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 32.8 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 52.7 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 83.9 seconds
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ → 137.8 seconds

This could be a denial of service vulnerability in an application that parses user input.

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