CVE-2021-42340
DoS via memory leak with WebSocket connections
Also known as BIT-tomcat-2021-42340, GHSA-wph7-x527-w3h5
Mitigation
- Upgrade org.apache.tomcat:tomcat to one of 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72 (or later in the same release line).
Who should check
- Projects that depend on Maven package org.apache.tomcat:tomcat (>= 10.1.0-M1, < 10.1.0-M6)
- Anyone running Apache Software Foundation Apache Tomcat Apache Tomcat 10 10.0.0-M10 to 10.0.11; Apache Tomcat 10 10.1.0-M1 to 10.1.0-M5; Apache Tomcat 9 9.0.40 to 9.0.53; Apache Tomcat 8 8.5.60 to 8.5.71
Vulnerability facts
- Affected
- org.apache.tomcat:tomcat >= 10.1.0-M1, < 10.1.0-M6
- Fixed in
- 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Remote, no login needed
- CVSS
- 7.5 (v3.1, NVD)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HOpen in CVSS calculator
Show all 8 CVSS metrics
- Attack vector: Network
- Attack complexity: Low
- Privileges required: None
- User interaction: None
- Scope: Unchanged
- Confidentiality impact: None
- Integrity impact: None
- Availability impact: High
- EPSS
- 10.82% chance of exploitation in 30 days (percentile 97, 2026-11-26)
- CWE
- CWE-772
- Modified
Description
The fix for bug 63362 present in Apache Tomcat 10.1.0-M1 to 10.1.0-M5, 10.0.0-M1 to 10.0.11, 9.0.40 to 9.0.53 and 8.5.60 to 8.5.71 introduced a memory leak. The object introduced to collect metrics for HTTP upgrade connections was not released for WebSocket connections once the connection was closed. This created a memory leak that, over time, could lead to a denial of service via an OutOfMemoryError.
Affected and fixed versions
| Package / product | Affected | Fixed | Source |
|---|---|---|---|
| Maven org.apache.tomcat:tomcat | >= 10.1.0-M1, < 10.1.0-M6 | 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72 | osv |
| Apache Software Foundation Apache Tomcat | Apache Tomcat 10 10.0.0-M10 to 10.0.11; Apache Tomcat 10 10.1.0-M1 to 10.1.0-M5; Apache Tomcat 9 9.0.40 to 9.0.53; Apache Tomcat 8 8.5.60 to 8.5.71 | — | cvelist |
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2021-42340. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2021-42340.md Affected: org.apache.tomcat:tomcat >= 10.1.0-M1, < 10.1.0-M6 Fixed in: 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72 Steps: 1. Search this machine and project for org.apache.tomcat:tomcat (Maven), Apache Software Foundation Apache Tomcat: dependency manifests and lockfiles, installed packages, container images and running services. 2. For each match, note the installed version and whether it is inside the affected range. 3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
References
Vendor advisories
Patches
- https://www.oracle.com/security-alerts/cpujan2022.html
- https://www.oracle.com/security-alerts/cpuapr2022.html
- https://www.oracle.com/security-alerts/cpujul2022.html
- https://github.com/apache/tomcat/commit/31d62426645824bdfe076a0c0eafa904d90b4fb9
- https://github.com/apache/tomcat/commit/80f1438ec45e77a07b96419808971838d259eb47
- https://github.com/apache/tomcat/commit/d27535bdee95d252418201eb21e9d29476aa6b6a
- https://github.com/apache/tomcat/commit/d5a6660cba7f51589468937bf3bbad4db7810371
Other
- https://lists.apache.org/thread.html/r8097a2d1550aa78e585fc77e602b9046e6d4099d8d132497c5387784%40%3Ccommits.myfaces.apache.org%3E
- https://security.netapp.com/advisory/ntap-20211104-0001/
- https://kc.mcafee.com/corporate/index?page=content&id=SB10379
- https://tomcat.apache.org/security-9.html
- https://tomcat.apache.org/security-8.html
- https://tomcat.apache.org/security-10.html
- https://security.netapp.com/advisory/ntap-20211104-0001
- https://lists.apache.org/thread.html/r8097a2d1550aa78e585fc77e602b9046e6d4099d8d132497c5387784@%3Ccommits.myfaces.apache.org%3E
- https://github.com/apache/tomcat
FAQ
Is CVE-2021-42340 being exploited?
There is no confirmed exploitation: CVE-2021-42340 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 10.82% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2021-42340?
High: CVSS 7.5 (v3.1, scored by NVD). Remote, no login needed.
Which versions are affected by CVE-2021-42340?
org.apache.tomcat:tomcat >= 10.1.0-M1, < 10.1.0-M6.
Is there a fix for CVE-2021-42340?
Yes. Fixed in 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72. Upgrade org.apache.tomcat:tomcat to one of 10.1.0-M6, 10.0.12, 9.0.54, 8.5.72 (or later in the same release line).
How do I check if I'm affected by CVE-2021-42340?
Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.