CVE-2021-36373: Ant Improper Handling Of Length Parameter Vulnerability

MODERATE
Advisory Identifier: GHSA-q5r4-cfpx-h6fh
CVSS 5.5
CWE-130
Published
Advisory Summary

CVE-2021-36373 is a MODERATE (CVSS 5.5) improper handling of length parameter vulnerability (CWE-130: Improper Handling of Length Parameter Inconsistency) affecting Ant libraries in the Maven ecosystem. The issue involves improper handling of length parameter inconsistency in apache ant. Remediation is available by upgrading affected packages to version 1.9.16, 1.10.11.

CVE-2021-36373 at a Glance

CVE Identifier CVE-2021-36373
GHSA Identifier GHSA-q5r4-cfpx-h6fh
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-130: Improper Handling of Length Parameter Inconsistency
Affected Product Ant
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 5.5

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

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

How to Fix CVE-2021-36373

To remediate this vulnerability, upgrade all affected Ant 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.ant:ant fixed: 1.9.16
<dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.9.16</version>
</dependency>
org.apache.ant:ant fixed: 1.10.11
<dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.10.11</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.ant

How to Check if You Are Affected

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

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

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

Note: The mvn dependency:tree -Dincludes=org.apache.ant 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-130: Improper Handling of Length Parameter Inconsistency, where the product parses a formatted message or structure, but it does not handle or incorrectly handles a length field that is inconsistent with the actual length of the associated data. In Ant, 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

When reading a specially crafted TAR archive an Apache Ant build can be made to allocate large amounts of memory that finally leads to an out of memory error, even for small inputs. This can be used to disrupt builds using Apache Ant. Apache Ant prior to 1.9.16 and 1.10.11 were affected.

CVE-2021-36373 Affected Ant Versions

2 component(s)
Fixed Versions:
1.9.161.10.11
Product / Package Ecosystem Affected Versions Fixed Version
org.apache.ant:ant
Maven
< 1.9.16
1.9.16
org.apache.ant:ant
Maven
≥ 1.10.0
< 1.10.11
1.10.11

References

Frequently Asked Questions

What is CVE-2021-36373?
CVE-2021-36373 is a security vulnerability in Ant involving Improper Handling of Length Parameter Inconsistency in Apache Ant under CWE-130: Improper Handling of Length Parameter Inconsistency.
Which Ant versions are affected?
Affected versions include releases prior to 1.9.16, 1.10.11 across affected packages: org.apache.ant:ant.
What version fixes CVE-2021-36373?
Upgrading to 1.9.16, 1.10.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ant affected?
Yes, org.apache.ant:ant is affected in releases prior to 1.9.16, 1.10.11. Upgrade your dependency to 1.9.16, 1.10.11 or later.
What is the CVSS score of CVE-2021-36373?
CVE-2021-36373 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-36373?
CVE-2021-36373 is classified under CWE-130: Improper Handling of Length Parameter Inconsistency (The product parses a formatted message or structure, but it does not handle or incorrectly handles a length field that is inconsistent with the actual length of the associated data.).
How can I check Maven dependencies for CVE-2021-36373?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.apache.ant'. 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-q5r4-cfpx-h6fh",
  "modified" : "2022-02-08T21:08:16Z",
  "published" : "2021-08-02T16:56:17Z",
  "aliases" : [ "CVE-2021-36373" ],
  "summary" : "Improper Handling of Length Parameter Inconsistency in Apache Ant",
  "details" : "When reading a specially crafted TAR archive an Apache Ant build can be made to allocate large amounts of memory that finally leads to an out of memory error, even for small inputs. This can be used to disrupt builds using Apache Ant. Apache Ant prior to 1.9.16 and 1.10.11 were affected.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.ant:ant"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.9.16"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.apache.ant:ant"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.10.0"
      }, {
        "fixed" : "1.10.11"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-36373"
  }, {
    "type" : "WEB",
    "url" : "https://ant.apache.org/security.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r27919fd4db07c487239c1d9771f480d89ce5ee2750aa9447309b709a@%3Ccommits.groovy.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r544c9e8487431768465b8b2d13982c75123109bd816acf839d46010d@%3Ccommits.groovy.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r54afdab05e01de970649c2d91a993f68a6b00cd73e6e34e16c832d46%40%3Cuser.ant.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rad36f470647c5a7c02dd78c9973356d2840766d132b597b6444e373a@%3Cnotifications.groovy.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rf4bb79751a02889623195715925e4fd8932dd3c97e0ade91395a96c6@%3Cdev.myfaces.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210819-0007"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujan2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuoct2021.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-130" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-07-15T19:15:21Z",
    "nvd_published_at" : "2021-07-14T07:15:00Z"
  }
}