CVE-2021-30640: Apache Tomcat Authentication Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-36qh-35cm-5w2w
CVSS 6.5
CWE-116 CWE-287 CWE-289
Published
Advisory Summary

CVE-2021-30640 is a MODERATE (CVSS 6.5) authentication bypass vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Apache Tomcat libraries in the Maven ecosystem. The issue involves authentication bypass by alternate name in apache tomcat. Remediation is available by upgrading affected packages to version 10.0.5, 9.0.45, 8.5.65.

CVE-2021-30640 at a Glance

CVE Identifier CVE-2021-30640
GHSA Identifier GHSA-36qh-35cm-5w2w
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Apache Tomcat
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-30640

To remediate this vulnerability, upgrade all affected Apache Tomcat dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.apache.tomcat:tomcat fixed: 10.0.5
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat</artifactId>
    <version>10.0.5</version>
</dependency>
org.apache.tomcat:tomcat fixed: 9.0.45
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat</artifactId>
    <version>9.0.45</version>
</dependency>
org.apache.tomcat:tomcat fixed: 8.5.65
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat</artifactId>
    <version>8.5.65</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.apache.tomcat

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-30640, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.apache.tomcat

Analyze the terminal output to locate any version of Apache Tomcat in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 10.0.5), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.apache.tomcat command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Apache Tomcat, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A vulnerability in the JNDI Realm of Apache Tomcat allows an attacker to authenticate using variations of a valid user name and/or to bypass some of the protection provided by the LockOut Realm. This issue affects Apache Tomcat 10.0.0-M1 to 10.0.5; 9.0.0.M1 to 9.0.45; 8.5.0 to 8.5.65.

CVE-2021-30640 Affected Apache Tomcat Versions

3 component(s)
Fixed Versions:
10.0.59.0.458.5.65
Product / Package Ecosystem Affected Versions Fixed Version
org.apache.tomcat:tomcat
Maven
≥ 10.0.0-M1
< 10.0.5
10.0.5
org.apache.tomcat:tomcat
Maven
≥ 9.0.0M1
< 9.0.45
9.0.45
org.apache.tomcat:tomcat
Maven
≥ 8.5.0
< 8.5.65
8.5.65

References

Frequently Asked Questions

What is CVE-2021-30640?
CVE-2021-30640 is a security vulnerability in Apache Tomcat involving Authentication Bypass by Alternate Name in Apache Tomcat under CWE-116: Improper Encoding or Escaping of Output.
Which Apache Tomcat versions are affected?
Affected versions include releases prior to 10.0.5, 9.0.45, 8.5.65 across affected packages: org.apache.tomcat:tomcat.
What version fixes CVE-2021-30640?
Upgrading to 10.0.5, 9.0.45, 8.5.65 (or the latest patched release for your respective branch) resolves the vulnerability.
Is tomcat affected?
Yes, org.apache.tomcat:tomcat is affected in releases prior to 10.0.5, 9.0.45, 8.5.65. Upgrade your dependency to 10.0.5, 9.0.45, 8.5.65 or later.
What is the CVSS score of CVE-2021-30640?
CVE-2021-30640 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N.
What CWE is associated with CVE-2021-30640?
CVE-2021-30640 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check Maven dependencies for CVE-2021-30640?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.apache.tomcat'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-36qh-35cm-5w2w",
  "modified" : "2022-02-08T21:08:59Z",
  "published" : "2021-08-13T15:21:24Z",
  "aliases" : [ "CVE-2021-30640" ],
  "summary" : "Authentication Bypass by Alternate Name in Apache Tomcat",
  "details" : "A vulnerability in the JNDI Realm of Apache Tomcat allows an attacker to authenticate using variations of a valid user name and/or to bypass some of the protection provided by the LockOut Realm. This issue affects Apache Tomcat 10.0.0-M1 to 10.0.5; 9.0.0.M1 to 9.0.45; 8.5.0 to 8.5.65.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.tomcat:tomcat"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "10.0.0-M1"
      }, {
        "fixed" : "10.0.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.tomcat:tomcat"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "9.0.0M1"
      }, {
        "fixed" : "9.0.45"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.tomcat:tomcat"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.5.0"
      }, {
        "fixed" : "8.5.65"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-30640"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r59f9ef03929d32120f91f4ea7e6e79edd5688d75d0a9b65fd26d1fe8%40%3Cannounce.tomcat.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2021/08/msg00009.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202208-34"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210827-0007"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-4952"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-4986"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com//security-alerts/cpujul2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujan2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuoct2021.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116", "CWE-287", "CWE-289" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-07-13T19:21:02Z",
    "nvd_published_at" : "2021-07-12T15:15:00Z"
  }
}