# CVE-2021-20332: Exposure of Sensitive Information to an Unauthorized Actor in MongoDB Rust Driver

> The MongoDB Rust Driver may leak authentication credentials to monitoring logs if connection pool event listeners are enabled.

- **Severity:** Medium 4.2 (`CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 2 Aug 2021
- **Updated:** 17 Sep 2024
- **Also known as:** GHSA-4rjr-3gj2-5crq

## What is CVE-2021-20332?

CVE-2021-20332 is a medium-severity vulnerability in MongoDB Rust Driver, published on 2 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

Specific MongoDB Rust Driver versions can include credentials used by the connection pool to authenticate connections in the monitoring event that is emitted when the pool is created. The user's logging infrastructure could then potentially ingest these events and unexpectedly leak the credentials. Note that such monitoring is not enabled by default. This issue affects MongoDB Rust Driver version 2.0.0-alpha, MongoDB Rust Driver version 2.0.0-alpha1 and MongoDB Rust Driver version 1.0.0 through to and including 1.2.1

Weakness: CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor)

## Which versions are affected by CVE-2021-20332?

2 open source packages ship an affected version, including mongodb. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mongodb` | crates.io | From 1.0.0 | 2.0.0-beta |
| `mongodb` | crates.io | From 1.0.0 | 2.0.0-beta |

Products: Mongodb Rust Driver.

## How do I fix CVE-2021-20332?

Upgrade mongodb to 2.0.0-beta or later.

## Is CVE-2021-20332 being exploited?

There is no known exploitation of CVE-2021-20332 in the wild and no public exploit code.

## Other vulnerabilities in MongoDB Rust Driver

- [CVE-2025-11695](https://insights.sbomify.com/CVE-2025-11695/): Configuration may unexpectedly disable certificate validation (high 8.0)
- [CVE-2026-81526](https://insights.sbomify.com/CVE-2026-81526/): Cross-database write redirection via unvalidated dotted database name in bulk write namespaces (high 7.1)
- [CVE-2024-6382](https://insights.sbomify.com/CVE-2024-6382/): Adversarial unsanitized input may cause MongoDB Rust Driver to issue unintended commands. (medium 6.4)
- [CVE-2026-88024](https://insights.sbomify.com/CVE-2026-88024/): GridFS data disclosure and deletion via query-operator injection in file IDs in the MongoDB Rust Driver (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-20332 and fix it if it is affected.

What it is: CVE-2021-20332 is a medium-severity vulnerability in MongoDB Rust Driver, published on 2 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-20332 in the wild and no public exploit code.

Affected packages and fixed versions:
- mongodb (crates.io): affected from 1.0.0; fixed in 2.0.0-beta
- mongodb (crates.io): affected from 1.0.0; fixed in 2.0.0-beta

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-20332/ (Markdown: https://insights.sbomify.com/CVE-2021-20332/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-20332
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-20332
- OSV: https://osv.dev/vulnerability/CVE-2021-20332

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-20332/
Summaries are generated and may contain mistakes; the official description above is the record.
