Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReDoS in three #21132

Closed
yetingli opened this issue Jan 23, 2021 · 1 comment
Closed

ReDoS in three #21132

yetingli opened this issue Jan 23, 2021 · 1 comment

Comments

@yetingli
Copy link
Contributor

Hi,

I would like to report a Regular Expression Denial of Service (REDoS) vulnerability in three.

It allows cause a denial of service when handling rgb or hsl colors.

The vulnerable regex is located in

if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {

To Reproduce

Steps to reproduce the behavior:

Code

var three = require('three')



function build_blank (n) {
 var ret = "rgb("
 for (var i = 0; i < n; i++) {
  ret += " "
 }

 return ret + "";
}

var Color = three.Color

var time = Date.now();
new Color(build_blank(50000))
var time_cost = Date.now() - time;
console.log(time_cost+" ms")

I am willing to suggest that you replace the regex /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/ with /^((?:rgb|hsl)a?)\(\s*([^\)\s]*)\)/

@mrdoob
Copy link
Owner

mrdoob commented Jan 25, 2021

I made a pull request for this: #21142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants