Skip to main content
Menu
Advisories

Credential exposure via sensitive connection string values included in parse-error messages

GHSA-F95Q-GC7C-2M45Published Updated GitHub

Description

When the MongoDB .NET/C# Driver failed to parse or validate a connection string, the resulting exception messages could include the offending value from the connection string. Because connection strings carry the username, password and other sensitive option values, these values could end up in application logs and error output. In addition, the ToString() implementations of MongoUrl, MongoUrlBuilder and ConnectionString returned the full connection string including credentials, and MongoServerAddress.ToString() / MongoCredential.ToString() exposed host, port and username.

Impact

Sensitive information, including database credentials, can be exposed to logs, error output or telemetry if exceptions from connection string parsing, or the ToString() output of the types above, are logged or displayed. This can occur from an inadvertent error in a connection string and does not require an attacker-controlled string.

Patches

Fixed in MongoDB.Driver 3.14.1:

  • ToString() on MongoUrl, MongoUrlBuilder and ConnectionString now returns a redacted URL. Usernames, passwords and other sensitive values are replaced with <redacted>.
  • MongoServerAddress.ToString() and MongoCredential.ToString() now return fixed type names.
  • Exception messages from connection-string parsing, SRV validation, address parsing and authentication no longer include user-supplied values.

Breaking change / action required: code that uses these ToString() results as a connection string, key or identifier will break.

  • MongoUrl: use url.Url instead of url.ToString().
  • MongoUrlBuilder: use builder.ToMongoUrl().Url instead of builder.ToString(), or pass builder.ToMongoUrl() directly to new MongoClient(...).
  • ConnectionString: there is no public accessor for the unredacted string; keep the original string.
  • MongoServerAddress: use $"{address.Host}:{address.Port}".
  • MongoCredential: read Username and Source.

Workarounds

Do not log exception messages or ToString() output of connection-string related types, or redact credentials from them before logging, until upgrading.

References

CSHARP-6205 / CVE-2026-129936

Affected versions

References

GitHub · mongodb/mongo-csharp-driver