Skip to content

v7.9.1

Latest

Choose a tag to compare

@github-actions github-actions released this 19 Nov 16:38
7a75a3c

7.9.1 (2026-11-19)

The MongoDB Node.js team is pleased to announce version 7.9.1 of the mongodb package!

Release Notes

Warning

Node Driver versions before 7.9.1 are affected by a security issue related to NUL characters in PLAIN authentication credentials changing the identity that the server authenticates. Users are encouraged to upgrade to the fixed version or mitigate as soon as possible.

Applications that use PLAIN authentication in affected versions can avoid this issue by rejecting any username or password that contains a NUL character (\0, or %00 in a connection string) before passing it to MongoClient.

Warning

Node Driver versions from 4.0.0 before 7.9.1 are affected by a security issue where credentials and other values from the connection string can appear in cleartext in error messages and in logged representations of the client. Users are encouraged to upgrade to the fixed version or mitigate as soon as possible.

Applications on affected versions can reduce their exposure by passing the username and password through the auth option instead of the connection string, and by not writing errors thrown by MongoClient, or the client and its options, to logs.

MongoClient now throws when the username or password for PLAIN authentication contains a NUL character

A NUL character separates the fields of the PLAIN message (RFC 4616), so it cannot be part of a username or password.

Now, a username or password that contains a NUL character, whether it comes from the connection string or from the options object, makes the MongoClient constructor throw before any authentication command is sent to the server. Other authentication mechanisms are not affected.

// Now fails:

// throws!
const client = new MongoClient('mongodb://ldap.example.com', {
  authMechanism: 'PLAIN',
  auth: {
    username: 'user\0name',
    password: process.env.PASSWORD
  }
});

// also throws:
// 'mongodb://user%00name:password@ldap.example.com/?authMechanism=PLAIN'

Errors and logged representations no longer include values from the connection string

Connection string components that the driver rejects from bad connection strings are often written to an application log along with the error. A malformed connection string may cause connection string partials to be indistinguishable from other parts (e.g: mongodb://username:12345 is indistinguishable from a host, when it's actually a set of credentials).

Now, errors raised while parsing the connection string do not contain text taken from it:

  • An invalid value for an option is no longer included in the error. The option is still named, using the driver's own spelling.
  • An unsupported option in the connection string is reported by its position among the options instead of by name.
  • A host that cannot be parsed is no longer included in the error or in its cause.
// Before: MongoRuntimeError: Unable to parse user:pa55word with URL
// Now:    MongoRuntimeError: Unable to parse host with URL
new MongoClient('mongodb://user:pa55word');

// Before: MongoParseError: Expected connectTimeoutMS to be stringified int value, got: pa55word
// Now:    MongoParseError: Expected connectTimeoutMS to be stringified int value
new MongoClient('mongodb://localhost/?connectTimeoutMS=pa55word');

Applications that match on the text of these errors need to be updated.

The username, password, proxyUsername, proxyPassword and tlsCertificateKeyFilePassword are also replaced with <redacted> when the client, its options or its credentials are passed to console.log, util.inspect or JSON.stringify. The values themselves are unchanged and can still be read from client.options.

Bug Fixes

Documentation

We invite you to try the mongodb library immediately, and report any issues to the NODE project.