Fix potential ReDoS by yetingli · Pull Request #37 · chalk/ansi-regex (original) (raw)

@yetingli

@yetingli

@Qix-

Hi, normally we'd appreciate an email prior to submitting security patches, please keep this in mind as it's a pretty typical part of responsible disclosure.

Can you also provide some context for the redos? What sorts of input will cause issues?

@yetingli

Thanks for reminding. Sorry, I can't find your email. Could you tell me your email?

@Qix-

Well cat is out of the bag now, just write here. You can find emails in the commit messages of repositories by the way.

@yetingli

Proof of Concept

import ansiRegex from 'ansi-regex';

for(var i = 1; i <= 50000; i++) { var time = Date.now(); var attack_str = "\u001B["+";".repeat(i*10000); ansiRegex().test(attack_str) var time_cost = Date.now() - time; console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms") }

The ReDOS is mainly due to the sub-patterns [[\\]()#;?]* and (?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*

@Qix-

Thank you for the reproduction and the patch, was able to reproduce.

I'll push out an update immediately.

@Qix-

Published as 6.0.1 - thanks again!

@sindresorhus

Thanks. It would have been good with a regression test to ensure we don't accidentally regress the regex in the future.

@bcoe bcoe mentioned this pull request

Sep 14, 2021

Qix- pushed a commit that referenced this pull request

Sep 14, 2021

@yetingli @Qix-

@carnil

@Qix-

AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H - 7.5 High

Yet another example of how laughably broken CVE scores are.

@mariusbutuc

This was referenced

Oct 13, 2021

This was referenced

Oct 28, 2021

MylesBorins pushed a commit to MylesBorins/ansi-regex that referenced this pull request

Nov 3, 2021

@yetingli @MylesBorins

MylesBorins pushed a commit to MylesBorins/ansi-regex that referenced this pull request

Nov 3, 2021

@yetingli @MylesBorins

MylesBorins added a commit to MylesBorins/ansi-regex that referenced this pull request

Nov 3, 2021

@MylesBorins

This is a backport of chalk@8d1d7cd

the test suite on the 3.0.0 branch is broken but I've manually verified that no additional tests are broken and that this patch fixes the REDOS

@Qix- Qix- mentioned this pull request

Nov 3, 2021

Qix- pushed a commit that referenced this pull request

Mar 12, 2022

@yetingli @Qix-

Qix- pushed a commit that referenced this pull request

Mar 27, 2022

@yetingli @Qix-

This was referenced

May 21, 2022

This was referenced

May 6, 2022

This was referenced

May 16, 2022

Simpdaddyjosh

heatherleeann

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chalk chalk locked as resolved and limited conversation to collaborators

Nov 21, 2022

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})