Denial of Service in mongodb

mongodb Updated 02 Oct 2025

Summary

03/09/2020
HIGH
Yes i
High
Not published

GHSA-mh5c-679w-hh4r: Denial of Service in mongodb. Affects mongodb versions < 3.1.13. Fixed in 3.1.13. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The mongodb package is an open-source NoSQL database that provides high performance, scalability, and flexibility for storing and retrieving data. It is widely used in various applications and platforms. However, versions prior to 3.1.13 are vulnerable to a Denial of Service (DoS) attack. This vulnerability occurs when the package fails to properly handle an exception when an invalid collection name is provided and the corresponding database does not exist. As a result, the application crashes, leading to a disruption in service availability.

Vulnerability Detail

The vulnerability in mongodb allows an attacker to exploit the application by intentionally providing an invalid collection name and non-existent database. When the application attempts to access the collection, it fails to catch the exception, causing the application to crash. This can result in a complete denial of service, rendering the application unavailable to legitimate users. The impact of this vulnerability can be severe, especially in production environments where the application's availability is crucial.

How To Fix

Minimum fixed version

3.1.13

This is the first release that contains the fix.

npm install mongodb@3.1.13

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, developers can implement proper input validation and error handling in their application code. By validating the collection name and checking for the existence of the database before accessing it, the application can gracefully handle such scenarios and prevent crashes. Here's an example in Node.js:

const MongoClient = require('mongodb').MongoClient;

const url = 'mongodb://localhost:27017';
const dbName = 'mydatabase';
const collectionName = 'mycollection';

MongoClient.connect(url, function(err, client) {
  if (err) {
    console.error('Failed to connect to MongoDB:', err);
    return;
  }

  const db = client.db(dbName);

  if (!db) {
    console.error('Database does not exist');
    return;
  }

  const collection = db.collection(collectionName);

  // Perform operations on the collection
});

Conclusion

The vulnerability in mongodb prior to version 3.1.13 can be exploited to cause a Denial of Service (DoS) attack, resulting in the application crashing and becoming unavailable. To mitigate this vulnerability, it is strongly advised to upgrade to version 3.1.13 or later. If upgrading is not possible, developers should implement proper input validation and error handling in their application code. Regularly monitoring for security updates and promptly applying them is crucial to protect against potential exploits. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mongodb →

Share this vulnerability

FAQ

The vulnerability can lead to a Denial of Service (DoS) attack, causing the application to crash and become unavailable to legitimate users.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your package-lock.json file and Vulert will analyze it for vulnerabilities in real-time.

Yes, developers can implement proper input validation and error handling in their application code to mitigate the risk of this vulnerability. See the 'workaround' section for an example in Node.js.

At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is always recommended to promptly apply security patches and updates to protect against potential exploits.

If upgrading to version 3.1.13 or later is not feasible, it is crucial to implement the provided workaround and ensure proper input validation and error handling in your application code. Additionally, consider implementing other security measures, such as network-level protections and access controls, to mitigate the risk.

Related vulnerabilities

Recent vulnerabilities recorded for mongodb.

How To Fix

Minimum fixed version

3.1.13

This is the first release that contains the fix.

npm install mongodb@3.1.13

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback