CVE-2020-7760: Regular expression denial of service in codemirror

codemirror Updated 02 Oct 2025

Summary

10/05/2021
Yes i
Moderate
5.3

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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

Minimum fixed version

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 →

Share this vulnerability

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.

How To Fix

Minimum fixed version

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback