CVE-2021-20331: Mongodb.driver MongoDB C# Driver Risk Of Vulnerability

MODERATE
Advisory Identifier: GHSA-p9rv-qgqw-jx2w
CVSS 4.9
CWE-200
Published
Advisory Summary

CVE-2021-20331 is a MODERATE (CVSS 4.9) mongodb c# driver risk of vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Mongodb.driver libraries in the NuGet ecosystem. The issue involves mongodb c# driver risk of exposing authentication data via command listener. Remediation is available by upgrading affected packages to version 2.12.2.

CVE-2021-20331 at a Glance

CVE Identifier CVE-2021-20331
GHSA Identifier GHSA-p9rv-qgqw-jx2w
Severity MODERATE
CVSS v3.1 Base Score 4.9
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Mongodb.driver
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 4.9

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

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

How to Fix CVE-2021-20331

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.

mongodb.driver fixed: 2.12.2
Upgrade mongodb.driver to 2.12.2
Verify Direct and Transitive Dependencies

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

inspect dependencies for mongodb.driver

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-20331, inspect your project dependencies for Mongodb.driver:

inspect dependencies for mongodb.driver

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 2.12.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. 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 MongoDB C# Driver may erroneously publish events containing authentication-related data to a command listener configured by an application. The published events may contain security-sensitive data when commands such as "saslStart", "saslContinue", "isMaster", "createUser", and "updateUser" are executed. Without due care, an application may inadvertently expose this authenticated-related information, e.g., by writing it to a log file. This issue only arises if an application enables the command listener feature (this is not enabled by default). This issue affects the MongoDB C# Driver 2.12 <= 2.12.1.

CVE-2021-20331 Affected Mongodb.driver Versions

1 component(s)
Fixed Versions:
2.12.2
Product / Package Ecosystem Affected Versions Fixed Version
mongodb.driver
NuGet
≥ 2.11.0
< 2.12.2
2.12.2

References

Frequently Asked Questions

What is CVE-2021-20331?
CVE-2021-20331 is a security vulnerability in Mongodb.driver involving MongoDB C# Driver Risk of Exposing Authentication Data via Command Listener under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Mongodb.driver versions are affected?
Affected versions include releases prior to 2.12.2 across affected packages: mongodb.driver.
What version fixes CVE-2021-20331?
Upgrading to 2.12.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mongodb.driver affected?
Yes, mongodb.driver is affected in releases prior to 2.12.2. Upgrade your dependency to 2.12.2 or later.
What is the CVSS score of CVE-2021-20331?
CVE-2021-20331 has a CVSS v3.1 base score of 4.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2021-20331?
CVE-2021-20331 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check NuGet dependencies for CVE-2021-20331?
Run the dependency tree command: 'inspect dependencies for mongodb.driver'. 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-p9rv-qgqw-jx2w",
  "modified" : "2024-01-23T18:44:22Z",
  "published" : "2022-05-24T19:02:24Z",
  "aliases" : [ "CVE-2021-20331" ],
  "summary" : "MongoDB C# Driver Risk of Exposing Authentication Data via Command Listener",
  "details" : "Specific versions of the MongoDB C# Driver may erroneously publish events containing authentication-related data to a command listener configured by an application. The published events may contain security-sensitive data when commands such as \"saslStart\", \"saslContinue\", \"isMaster\", \"createUser\", and \"updateUser\" are executed. Without due care, an application may inadvertently expose this authenticated-related information, e.g., by writing it to a log file. This issue only arises if an application enables the command listener feature (this is not enabled by default). This issue affects the MongoDB C# Driver 2.12 <= 2.12.1.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "mongodb.driver"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.11.0"
      }, {
        "fixed" : "2.12.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-20331"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mongodb/mongo-csharp-driver/commit/1f1a526e93ed7aa254759704b19f5ee66a3af365"
  }, {
    "type" : "WEB",
    "url" : "https://jira.mongodb.org/browse/CSHARP-3521"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-20T20:26:56Z",
    "nvd_published_at" : "2021-05-13T08:15:00Z"
  }
}