CVE-2025-1691: MongoDB mongosh control character injection in autocomplete

CVE-2025-1691 · Severity: low · CVSS 3.1 · Published 2025-02-27

MongoDB Shell (mongosh) is a command-line tool used by database administrators and developers to interact with MongoDB databases. An attacker who controls a MongoDB cluster can inject hidden malicious commands that execute when a user presses tab to autocomplete text, bypassing normal visibility and obfuscating the attack. The vulnerability requires the user to be connected to the attacker's cluster and interact with the autocomplete feature, but successful exploitation could allow unauthorized access to data or system compromise.

Technologies: mongosh (npm). Vendors: npm.

Quick answers

Is CVE-2025-1691 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2025-1691 being exploited in the wild.
How severe is CVE-2025-1691?
Low severity, with a CVSS score of 3.1, published 27 February 2025.
Which products and versions are affected?
mongosh (npm) SEMVER:introduced=0,fixed=2.3.9.
Is there a fix for CVE-2025-1691?
Yes. mongosh (npm): upgrade to 2.3.9 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2025-1691 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2025-1691?
Check whether you run mongosh (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • mongosh (npm): upgrade to 2.3.9 or later
    npm install mongosh@2.3.9

Technical details

The vulnerability is an improper neutralization of special elements in output (CWE-74) within mongosh's autocomplete mechanism. When autocompleting text, the shell fails to properly sanitize control characters that could be used to inject and obfuscate malicious commands. An attacker with partial or full control of a MongoDB cluster can craft malicious autocompletion entries that appear benign but contain hidden control characters and payload instructions. The attack vector is network-based and requires the user to: (1) connect to an attacker-controlled MongoDB cluster, (2) type a prefix that matches the attacker's prepared autocompletion, and (3) press tab to trigger autocompletion. The attacker must have administrative privileges (PR:H) and user interaction is required (UI:R). The impact is high, affecting confidentiality, integrity, and availability across trust boundaries (S:C). The fix is available in mongosh version 2.3.9 and later.

Affected products

  • MongoDB mongosh prior to 2.3.9

Identifiers

  • CVE-2025-1691
  • GHSA-43g5-2wr2-q7vj

Timeline

  • 2025-02-27: disclosed
  • 2025-02-27: patched: Fixed in version 2.3.9

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.