CVE Vulnerabilities

CVE-2021-42340

Missing Release of Resource after Effective Lifetime

Published: Oct 14, 2021 | Modified: Nov 07, 2023
CVSS 3.x
7.5
HIGH
Source:
NVD
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CVSS 2.x
5 MEDIUM
AV:N/AC:L/Au:N/C:N/I:N/A:P
RedHat/V2
RedHat/V3
7.5 IMPORTANT
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Ubuntu
MEDIUM

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.

Weakness

The product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.

Affected Software

Name Vendor Start Version End Version
Tomcat Apache 8.5.60 (including) 8.5.72 (excluding)
Tomcat Apache 9.0.40 (including) 9.0.54 (excluding)
Tomcat Apache 10.0.1 (including) 10.0.12 (excluding)
Tomcat Apache 10.0.0-milestone10 (including) 10.0.0-milestone10 (including)
Tomcat Apache 10.1.0-milestone1 (including) 10.1.0-milestone1 (including)
Tomcat Apache 10.1.0-milestone2 (including) 10.1.0-milestone2 (including)
Tomcat Apache 10.1.0-milestone3 (including) 10.1.0-milestone3 (including)
Tomcat Apache 10.1.0-milestone4 (including) 10.1.0-milestone4 (including)
Tomcat Apache 10.1.0-milestone5 (including) 10.1.0-milestone5 (including)
Red Hat Enterprise Linux 9 RedHat pki-servlet-engine-1:9.0.50-1.el9 *
Red Hat Fuse 7.11 RedHat tomcat *
Red Hat JBoss Web Server 5 RedHat tomcat *
Red Hat JBoss Web Server 5.6 on RHEL 7 RedHat jws5-tomcat-0:9.0.50-3.redhat_00004.1.el7jws *
Red Hat JBoss Web Server 5.6 on RHEL 7 RedHat jws5-tomcat-native-0:1.2.30-3.redhat_3.el7jws *
Red Hat JBoss Web Server 5.6 on RHEL 7 RedHat jws5-tomcat-vault-0:1.1.8-4.Final_redhat_00004.1.el7jws *
Red Hat JBoss Web Server 5.6 on RHEL 8 RedHat jws5-tomcat-0:9.0.50-3.redhat_00004.1.el8jws *
Red Hat JBoss Web Server 5.6 on RHEL 8 RedHat jws5-tomcat-native-0:1.2.30-3.redhat_3.el8jws *
Red Hat JBoss Web Server 5.6 on RHEL 8 RedHat jws5-tomcat-vault-0:1.1.8-4.Final_redhat_00004.1.el8jws *
Red Hat Support for Spring Boot 2.5.10 RedHat tomcat *
Tomcat8 Ubuntu bionic *
Tomcat8 Ubuntu esm-apps/bionic *
Tomcat8 Ubuntu esm-infra/xenial *
Tomcat8 Ubuntu trusty *
Tomcat8 Ubuntu xenial *
Tomcat9 Ubuntu bionic *
Tomcat9 Ubuntu esm-apps/bionic *
Tomcat9 Ubuntu esm-apps/focal *
Tomcat9 Ubuntu focal *
Tomcat9 Ubuntu hirsute *
Tomcat9 Ubuntu impish *
Tomcat9 Ubuntu kinetic *
Tomcat9 Ubuntu lunar *
Tomcat9 Ubuntu mantic *
Tomcat9 Ubuntu trusty *
Tomcat9 Ubuntu xenial *

Potential Mitigations

  • Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
  • For example, languages such as Java, Ruby, and Lisp perform automatic garbage collection that releases memory for objects that have been deallocated.
  • Use resource-limiting settings provided by the operating system or environment. For example, when managing system resources in POSIX, setrlimit() can be used to set limits for certain types of resources, and getrlimit() can determine how many resources are available. However, these functions are not available on all operating systems.
  • When the current levels get close to the maximum that is defined for the application (see CWE-770), then limit the allocation of further resources to privileged users; alternately, begin releasing resources for less-privileged users. While this mitigation may protect the system from attack, it will not necessarily stop attackers from adversely impacting other users.
  • Ensure that the application performs the appropriate error checks and error handling in case resources become unavailable (CWE-703).

References