# CVE-2021-21391: Regular expression Denial of Service in multiple packages


- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 29 Apr 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-3rh3-wfr4-76mj, UBUNTU-CVE-2021-21391

## What is CVE-2021-21391?

CVE-2021-21391 is a medium-severity vulnerability in ckeditor5, published on 29 Apr 2021. 

### Official description

CKEditor 5 provides a WYSIWYG editing solution. This CVE affects the following npm packages: ckeditor5-engine, ckeditor5-font, ckeditor5-image, ckeditor5-list, ckeditor5-markdown-gfm, ckeditor5-media-embed, ckeditor5-paste-from-office, and ckeditor5-widget. Following an internal audit, a regular expression denial of service (ReDoS) vulnerability has been discovered in multiple CKEditor 5 packages. The vulnerability allowed to abuse particular regular expressions, which could cause a significant performance drop resulting in a browser tab freeze. It affects all users using the CKEditor 5 packages listed above at version <= 26.0.0. The problem has been recognized and patched. The fix will be available in version 27.0.0.

Weakness: CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2021-21391?

16 open source packages ship an affected version, including @ckeditor/ckeditor5-engine, @ckeditor/ckeditor5-font and @ckeditor/ckeditor5-image. It affects 8 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@ckeditor/ckeditor5-engine` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-engine` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-font` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-font` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-image` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-image` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-list` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-list` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-markdown-gfm` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-markdown-gfm` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-media-embed` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-media-embed` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-paste-from-office` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-paste-from-office` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-widget` | npm | All versions | 27.0.0 |
| `@ckeditor/ckeditor5-widget` | npm | All versions | 27.0.0 |

Products: Ckeditor Ckeditor5-Engine, Ckeditor Ckeditor5-Font, Ckeditor Ckeditor5-Image, Ckeditor Ckeditor5-List, Ckeditor Ckeditor5-Markdown-Gfm, Ckeditor Ckeditor5-Media-Embed, Ckeditor Ckeditor5-Paste-From-Office, Ckeditor Ckeditor5-Widget.

## How do I fix CVE-2021-21391?

Upgrade @ckeditor/ckeditor5-engine to 27.0.0 or later.

## Is CVE-2021-21391 being exploited?

There is no known exploitation of CVE-2021-21391 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21391 and fix it if it is affected.

What it is: CVE-2021-21391 is a medium-severity vulnerability in ckeditor5, published on 29 Apr 2021. 
Exploitation: There is no known exploitation of CVE-2021-21391 in the wild and no public exploit code.

Affected packages and fixed versions:
- @ckeditor/ckeditor5-engine (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-engine (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-font (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-font (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-image (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-image (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-list (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-list (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-markdown-gfm (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-markdown-gfm (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-media-embed (npm): affected all versions; fixed in 27.0.0
- @ckeditor/ckeditor5-media-embed (npm): affected all versions; fixed in 27.0.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-21391/ (Markdown: https://insights.sbomify.com/CVE-2021-21391/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-21391
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-21391
- OSV: https://osv.dev/vulnerability/CVE-2021-21391

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-21391/
Summaries are generated and may contain mistakes; the official description above is the record.
