CVE-2020-7760: Codemirror Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-4gw3-8f77-f72c
CVSS 5.3
CWE-400
Published
Advisory Summary

CVE-2020-7760 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Codemirror libraries in the npm ecosystem. The issue involves regular expression denial of service in codemirror. Remediation is available by upgrading affected packages to version 5.58.2.

CVE-2020-7760 at a Glance

CVE Identifier CVE-2020-7760
GHSA Identifier GHSA-4gw3-8f77-f72c
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Codemirror
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:L).

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 Low (A:L)

How to Fix CVE-2020-7760

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

codemirror fixed: 5.58.2
npm install codemirror@5.58.2
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 codemirror

How to Check if You Are Affected

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

npm ls codemirror

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

Note: The npm ls codemirror 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 Codemirror, 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

This affects the package codemirror before 5.58.2; the package org.apache.marmotta.webjars:codemirror before 5.58.2. The vulnerable regular expression is located in https://github.com/codemirror/CodeMirror/blob/cdb228ac736369c685865b122b736cd0d397836c/mode/javascript/javascript.jsL129. The ReDOS vulnerability of the regex is mainly due to the sub-pattern (s|/*.*?*/)*

CVE-2020-7760 Affected Codemirror Versions

1 component(s)
Fixed Versions:
5.58.2
Product / Package Ecosystem Affected Versions Fixed Version
codemirror
npm
< 5.58.2
5.58.2

References

Frequently Asked Questions

What is CVE-2020-7760?
CVE-2020-7760 is a security vulnerability in Codemirror involving Regular expression denial of service in codemirror under CWE-400: Uncontrolled Resource Consumption.
Which Codemirror versions are affected?
Affected versions include releases prior to 5.58.2 across affected packages: codemirror.
What version fixes CVE-2020-7760?
Upgrading to 5.58.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is codemirror affected?
Yes, codemirror is affected in releases prior to 5.58.2. Upgrade your dependency to 5.58.2 or later.
What is the CVSS score of CVE-2020-7760?
CVE-2020-7760 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2020-7760?
CVE-2020-7760 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-2020-7760?
Run the dependency tree command: 'npm ls codemirror'. 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-4gw3-8f77-f72c",
  "modified" : "2021-04-21T17:29:09Z",
  "published" : "2021-05-10T18:46:27Z",
  "aliases" : [ "CVE-2020-7760" ],
  "summary" : "Regular expression denial of service in codemirror",
  "details" : "This affects the package codemirror before 5.58.2; the package org.apache.marmotta.webjars:codemirror before 5.58.2.\n The vulnerable regular expression is located in https://github.com/codemirror/CodeMirror/blob/cdb228ac736369c685865b122b736cd0d397836c/mode/javascript/javascript.jsL129. The ReDOS vulnerability of the regex is mainly due to the sub-pattern (s|/*.*?*/)*",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "codemirror"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.58.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-7760"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/codemirror/CodeMirror/commit/55d0333907117c9231ffdf555ae8824705993bbb"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGAPACHEMARMOTTAWEBJARS-1024450"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1024449"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1024445"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBCODEMIRROR-1024448"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBCOMPONENTS-1024446"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1024447"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-CODEMIRROR-1016937"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2020/dsa-4789"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/codemirror"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com//security-alerts/cpujul2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuApr2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-21T17:29:09Z",
    "nvd_published_at" : "2020-10-30T11:15:00Z"
  }
}