Vulnerabilities in pkg:maven/org.mongodb/mongodb-driver

PACKAGE
Advisory Identifier: GHSA-rghw-6px2-fgwc
Advisory Summary

CVE-2021-20328 is a MODERATE (CVSS 6.8) improper certificate validation vulnerability (CWE-295: Improper Certificate Validation) affecting Mongodb driver libraries in the Maven ecosystem. The issue involves improper certificate validation in mongodb. Remediation is available by upgrading affected packages to version 3.11.3, 3.12.8, 4.0.6, 4.1.2, 4.2.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.mongodb/mongodb-driver

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.mongodb/mongodb-driver. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-rghw-6px2-fgwc CVE-2021-20328 MODERATE Improper Certificate Validation in MongoDB

CVE-2021-20328 at a Glance

CVE Identifier CVE-2021-20328
GHSA Identifier GHSA-rghw-6px2-fgwc
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-295: Improper Certificate Validation
Affected Product Mongodb driver
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 6.8

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

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

How to Fix CVE-2021-20328

To remediate this vulnerability, upgrade all affected Mongodb driver 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.mongodb:mongodb-driver fixed: 3.11.3
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver</artifactId>
    <version>3.11.3</version>
</dependency>
org.mongodb:mongodb-driver fixed: 3.12.8
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver</artifactId>
    <version>3.12.8</version>
</dependency>
org.mongodb:mongodb-driver-sync fixed: 4.0.6
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.0.6</version>
</dependency>
org.mongodb:mongodb-driver-sync fixed: 4.1.2
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.1.2</version>
</dependency>
org.mongodb:mongodb-driver-sync fixed: 4.2.1
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.2.1</version>
</dependency>
org.mongodb:mongo-java-driver fixed: 3.11.3
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.11.3</version>
</dependency>
org.mongodb:mongo-java-driver fixed: 3.12.8
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    <version>3.12.8</version>
</dependency>
org.mongodb:mongodb-driver-legacy fixed: 4.0.6
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-legacy</artifactId>
    <version>4.0.6</version>
</dependency>
org.mongodb:mongodb-driver-legacy fixed: 4.1.2
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-legacy</artifactId>
    <version>4.1.2</version>
</dependency>
org.mongodb:mongodb-driver-legacy fixed: 3.11.3
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-legacy</artifactId>
    <version>3.11.3</version>
</dependency>
org.mongodb:mongodb-driver-legacy fixed: 3.12.8
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-legacy</artifactId>
    <version>3.12.8</version>
</dependency>
org.mongodb:mongodb-driver-sync fixed: 3.12.8
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>3.12.8</version>
</dependency>
org.mongodb:mongodb-driver-sync fixed: 3.11.3
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>3.11.3</version>
</dependency>
org.mongodb:mongodb-driver-legacy fixed: 4.2.1
<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-legacy</artifactId>
    <version>4.2.1</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.mongodb

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=org.mongodb

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

Note: The mvn dependency:tree -Dincludes=org.mongodb 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-295: Improper Certificate Validation, where the product does not validate, or incorrectly validates, a certificate. In Mongodb driver, 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

Specific versions of the Java driver that support client-side field level encryption (CSFLE) fail to perform correct host name verification on the KMS server’s certificate. This vulnerability in combination with a privileged network position active MITM attack could result in interception of traffic between the Java driver and the KMS service rendering Field Level Encryption ineffective. This issue was discovered during internal testing and affects all versions of the Java driver that support CSFLE. The Java async, Scala, and reactive streams drivers are not impacted. This vulnerability does not impact driver traffic payloads with CSFLE-supported key services originating from applications residing inside the AWS, GCP, and Azure network fabrics due to compensating controls in these environments. This issue does not impact driver workloads that don’t use Field Level Encryption.

CVE-2021-20328 Affected Mongodb driver Versions

14 component(s)
Fixed Versions:
3.11.33.12.84.0.64.1.24.2.1
Product / Package Ecosystem Affected Versions Fixed Version
org.mongodb:mongodb-driver
Maven
≥ 3.11.0
< 3.11.3
3.11.3
org.mongodb:mongodb-driver
Maven
≥ 3.12.0
< 3.12.8
3.12.8
org.mongodb:mongodb-driver-sync
Maven
≥ 4.0.0
< 4.0.6
4.0.6
org.mongodb:mongodb-driver-sync
Maven
≥ 4.1.0
< 4.1.2
4.1.2
org.mongodb:mongodb-driver-sync
Maven
≥ 4.2.0
< 4.2.1
All 1 versions
4.2.0
4.2.1
org.mongodb:mongo-java-driver
Maven
≥ 3.11.0
< 3.11.3
3.11.3
org.mongodb:mongo-java-driver
Maven
≥ 3.12.0
< 3.12.8
3.12.8
org.mongodb:mongodb-driver-legacy
Maven
≥ 4.0.0
< 4.0.6
4.0.6
org.mongodb:mongodb-driver-legacy
Maven
≥ 4.1.0
< 4.1.2
4.1.2
org.mongodb:mongodb-driver-legacy
Maven
≥ 3.11.0
< 3.11.3
3.11.3
org.mongodb:mongodb-driver-legacy
Maven
≥ 3.12.0
< 3.12.8
3.12.8
org.mongodb:mongodb-driver-sync
Maven
≥ 3.12.0
< 3.12.8
3.12.8
org.mongodb:mongodb-driver-sync
Maven
≥ 3.11.0
< 3.11.3
3.11.3
org.mongodb:mongodb-driver-legacy
Maven
≥ 4.2.0
< 4.2.1
All 1 versions
4.2.0
4.2.1

References

Frequently Asked Questions

What is CVE-2021-20328?
CVE-2021-20328 is a security vulnerability in Mongodb driver involving Improper Certificate Validation in MongoDB under CWE-295: Improper Certificate Validation.
Which Mongodb driver versions are affected?
Affected versions include releases prior to 3.11.3, 3.12.8, 4.0.6, 4.1.2, 4.2.1 across affected packages: org.mongodb:mongodb-driver, org.mongodb:mongodb-driver-sync, org.mongodb:mongo-java-driver, org.mongodb:mongodb-driver-legacy.
What version fixes CVE-2021-20328?
Upgrading to 3.11.3, 3.12.8, 4.0.6, 4.1.2, 4.2.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mongodb-driver affected?
Yes, org.mongodb:mongodb-driver is affected in releases prior to 3.11.3, 3.12.8. Upgrade your dependency to 3.11.3, 3.12.8 or later.
Is mongodb-driver-sync affected?
Yes, org.mongodb:mongodb-driver-sync is affected in releases prior to 4.0.6, 4.1.2, 4.2.1, 3.12.8, 3.11.3. Upgrade your dependency to 4.0.6, 4.1.2, 4.2.1, 3.12.8, 3.11.3 or later.
What is the CVSS score of CVE-2021-20328?
CVE-2021-20328 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-20328?
CVE-2021-20328 is classified under CWE-295: Improper Certificate Validation (The product does not validate, or incorrectly validates, a certificate.).
How can I check Maven dependencies for CVE-2021-20328?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.mongodb'. 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-rghw-6px2-fgwc",
  "modified" : "2024-02-13T19:27:59Z",
  "published" : "2022-05-24T22:28:56Z",
  "aliases" : [ "CVE-2021-20328" ],
  "summary" : "Improper Certificate Validation in MongoDB",
  "details" : "Specific versions of the Java driver that support client-side field level encryption (CSFLE) fail to perform correct host name verification on the KMS server’s certificate. This vulnerability in combination with a privileged network position active MITM attack could result in interception of traffic between the Java driver and the KMS service rendering Field Level Encryption ineffective. This issue was discovered during internal testing and affects all versions of the Java driver that support CSFLE. The Java async, Scala, and reactive streams drivers are not impacted. This vulnerability does not impact driver traffic payloads with CSFLE-supported key services originating from applications residing inside the AWS, GCP, and Azure network fabrics due to compensating controls in these environments. This issue does not impact driver workloads that don’t use Field Level Encryption.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.11.0"
      }, {
        "fixed" : "3.11.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.2"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.12.0"
      }, {
        "fixed" : "3.12.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.12.7"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.0.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0"
      }, {
        "fixed" : "4.1.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.1"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.2.0"
      }, {
        "fixed" : "4.2.1"
      } ]
    } ],
    "versions" : [ "4.2.0" ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongo-java-driver"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.11.0"
      }, {
        "fixed" : "3.11.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.2"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongo-java-driver"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.12.0"
      }, {
        "fixed" : "3.12.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.12.7"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.0.5"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0"
      }, {
        "fixed" : "4.1.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.1.1"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.11.0"
      }, {
        "fixed" : "3.11.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.2"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.12.0"
      }, {
        "fixed" : "3.12.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.12.7"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.12.0"
      }, {
        "fixed" : "3.12.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.12.7"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-sync"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.11.0"
      }, {
        "fixed" : "3.11.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.2"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.mongodb:mongodb-driver-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.2.0"
      }, {
        "fixed" : "4.2.1"
      } ]
    } ],
    "versions" : [ "4.2.0" ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-20328"
  }, {
    "type" : "WEB",
    "url" : "https://jira.mongodb.org/browse/JAVA-4017"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-295" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-22T18:49:12Z",
    "nvd_published_at" : "2021-02-25T17:15:00Z"
  }
}