CVE-2020-7760: Regular expression denial of service in codemirror
Summary
CVE-2020-7760: Regular expression denial of service in codemirror. Affects codemirror versions < 5.58.2. Fixed in 5.58.2. How to fix ↓
Also tracked for
- codemirror-js · Debian:11
The same CVE-2020-7760 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
CodeMirror is a versatile text editor implemented in JavaScript for use in web applications. It provides a rich set of features for code editing, including syntax highlighting, autocompletion, and code folding. The vulnerable version of CodeMirror, before 5.58.2, is susceptible to a regular expression denial of service (ReDOS) attack. This vulnerability also affects the package org.apache.marmotta.webjars:codemirror before 5.58.2.
Vulnerability Detail
The vulnerability arises from a regular expression located in the JavaScript mode of CodeMirror. The specific vulnerable regex pattern can be found at line 129 of the javascript.js file. The ReDOS vulnerability is primarily caused by the sub-pattern (s|/.?/). An attacker can exploit this vulnerability by providing a specially crafted input that triggers excessive backtracking in the regular expression engine, leading to a denial of service condition. The impact of this vulnerability is moderate, with a CVSS score of 5.3.
How To Fix
Latest published version: 6.0.2 as of 23 Oct 2026
npm install codemirror@6.0.2
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
5.58.2
This is the first release that contains the fix.
npm install codemirror@5.58.2
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the package is not immediately feasible, a temporary workaround is to avoid using the vulnerable regular expression pattern or modify it to reduce the risk of ReDOS attacks. Here is an example of a modified pattern that mitigates the vulnerability:
var pattern = /(s|\/*[^*]*\*+([^/*][^*]*\*+)*\/*)/;
Conclusion
The CodeMirror package before version 5.58.2 is vulnerable to a regular expression denial of service (ReDOS) attack. It is recommended to update the package to the latest version to mitigate this vulnerability. If immediate updating is not possible, developers can apply the provided workaround or contact DevNack.com for further assistance in resolving the vulnerability.
See every vulnerability recorded for codemirror →
FAQ
CodeMirror is a JavaScript-based text editor used in web applications for code editing.
A ReDOS attack is a type of denial of service attack that exploits the backtracking behavior of certain regular expressions, causing the regex engine to consume excessive time and resources.
The impact of this vulnerability is moderate, with a CVSS score of 5.3. It can lead to a denial of service condition, potentially affecting the availability of the affected application.
To fix this vulnerability, update the CodeMirror package to version 5.58.2 or later. Alternatively, modify the vulnerable regular expression pattern to reduce the risk of ReDOS attacks.
Yes, a temporary workaround is to avoid using the vulnerable regular expression pattern or modify it as described in the 'workaround' section.