# GHSA-F95Q-GC7C-2M45: Credential exposure via sensitive connection string values included in parse-error messages

- Database: GitHub
- Severity: medium (stated by ghsa, no CVSS score)
- Published: 2026-11-19
- Modified: 2026-11-19

## Tracked as

- [CVE-2026-129936](https://cve.now/CVE-2026-129936.md): MongoDB C# Driver credential exposure via unmasked connection string parsing

## Affected versions

- MongoDB.Driver (NuGet): from 2.0.0, fixed in 3.14.1

## Description

### Summary

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](https://jira.mongodb.org/browse/CSHARP-6205) / [CVE-2026-129936](https://www.cve.org/CVERecord?id=CVE-2026-129936)

## References

- https://github.com/mongodb/mongo-csharp-driver/security/advisories/GHSA-f95q-gc7c-2m45

Page: https://cve.now/GHSA-F95Q-GC7C-2M45
