# CVE-2021-20327: MongoDB Node.js client side field level encryption library may not be validating KMS certificate

> An attacker with privileged network position can intercept traffic and bypass client-side field level encryption due to missing KMS certificate validation.

- **Severity:** Medium 6.4 (`CVSS:3.1/AV:A/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 25 Feb 2021
- **Updated:** 16 Sep 2024
- **Also known as:** GHSA-rjmf-p882-645m

## What is CVE-2021-20327?

CVE-2021-20327 is a medium-severity vulnerability in MongoDB Node.js Driver mongodb-client-encryption module, published on 25 Feb 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

A specific version of the Node.js mongodb-client-encryption module does not perform correct validation of 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 Node.js driver and the KMS service rendering client-side field level encryption (CSFLE) ineffective. This issue was discovered during internal testing and affects mongodb-client-encryption module version 1.2.0, which was available from 2021-Jan-29 and deprecated in the NPM Registry on 2021-Feb-04. This vulnerability does not impact driver traffic payloads with CSFLE-supported key services from applications residing inside the AWS, GCP, and Azure nework fabrics due to compensating controls in these environments. This issue does not impact driver workloads that don’t use Field Level Encryption. This issue affect MongoDB Node.js Driver mongodb-client-encryption module version 1.2.0

Weakness: CWE-295 (Improper Certificate Validation)

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

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `mongodb-client-encryption` | npm | From 1.2.0 | 1.2.1 |
| `mongodb-client-encryption` | npm | From 1.2.0 | 1.2.1 |

Products: Mongodb Mongodb Client Encryption.

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

Upgrade mongodb-client-encryption to 1.2.1 or later.

## Is CVE-2021-20327 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2021-20327 is a medium-severity vulnerability in MongoDB Node.js Driver mongodb-client-encryption module, published on 25 Feb 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-20327 in the wild and no public exploit code.

Affected packages and fixed versions:
- mongodb-client-encryption (npm): affected from 1.2.0; fixed in 1.2.1
- mongodb-client-encryption (npm): affected from 1.2.0; fixed in 1.2.1

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-20327/ (Markdown: https://insights.sbomify.com/CVE-2021-20327/index.md)
```

## Sources

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

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