Skip to content

CSHARP-6206: KMS master key exposure via unredacted credential serialization in driver settings string (port to main branch) - #2113

Open
papafe wants to merge 1 commit into
mongodb:mainfrom
papafe:csharp6206
Open

CSHARP-6206: KMS master key exposure via unredacted credential serialization in driver settings string (port to main branch)#2113
papafe wants to merge 1 commit into
mongodb:mainfrom
papafe:csharp6206

Conversation

@papafe

@papafe papafe commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

…ization in driver settings string (port to main branch)
@papafe
papafe requested a review from a team as a code owner September 2, 2026 09:23
@papafe
papafe requested review from ajcvickers and a lite review from Copilot September 2, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped to string serialization, includes targeted test updates/additions, and effectively prevents credential exposure without affecting operational encryption behavior.

Pull request overview

This PR addresses a security issue in the C# driver’s settings string representation by ensuring KMS provider credentials are not serialized in AutoEncryptionOptions.ToString() (which is surfaced via MongoClientSettings.ToString()), preventing accidental leakage of sensitive key material into logs/telemetry.

Changes:

  • Redacts all KMS provider option values in AutoEncryptionOptions.ToString() while retaining provider names.
  • Updates the existing ToString_should_return_expected_result test to match the redacted output.
  • Adds tests to verify KMS provider credentials are not exposed and that empty kmsProviders are rendered correctly.
File summaries
File Description
src/MongoDB.Driver/AutoEncryptionOptions.cs Changes ToString() to emit KmsProviders as { "<provider>" : "<hidden>" } for each provider, preventing credential/key leakage.
tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionOptionsTests.cs Updates/extends ToString() assertions to validate redaction behavior and empty-provider formatting.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@papafe papafe added the bug Fixes issues or unintended behavior. label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes issues or unintended behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants