Do not trace raw credential output - #2101
Draft
tyrielv wants to merge 1 commit into
Draft
Conversation
TryGetCredential and TryGetCertificatePassword added the raw stdout of "git credential fill" to the activity metadata when the parse of the output failed. That output is a list of "key=value" lines and includes the plaintext secret, so a failed parse wrote the secret to the log and to telemetry. Trace only the key names that the credential helper returned. The key names keep the diagnostic value of the trace, and the values never leave the process. Add unit tests that assert a sentinel secret does not appear in the activity metadata for either method. MockTracer now records the metadata that is passed to Stop so tests can inspect it. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GitProcess.TryGetCredentialandGitProcess.TryGetCertificatePasswordadded the raw stdout ofgit credential fillto the activity metadata when the parse of that output failed.git credential fillwrites its result as a list ofkey=valuelines:The methods compute
successfrom whether the expected values parsed. A helper can return a secret and still fail the parse — for example the username is absent, or the last line has no terminating newline, soParseValuereturns null. On that path the code wrote the entire raw stdout, including the plaintext secret, into the log and into telemetry.Fix
Trace only the key names that the credential helper returned. A new private helper
GetCredentialOutputKeysmaps the output to a comma-joined list of key names, and the metadata key changes fromOutputtoOutputKeys. Knowing which keys came back keeps the diagnostic value; the values never leave the process.Tests
GitProcessCredentialTestscovers both methods. Each test makes the parse fail with a distinctive sentinel secret in the output, then asserts that the sentinel is absent from every value in the activity metadata and thatOutputKeyslists the expected key names.MockTracernow records the metadata that is passed toStop, so tests can inspect what an activity reports.Verified by mutation: with the redaction reverted, both tests fail on the secret assertion. With the fix in place the unit-test suite is green (919 passed, 0 failed).
Notes
This targets
vnext. The defect is long-standing, not a 2.0 regression, and the change alters what the credential path reports at runtime.Scope is limited to the telemetry leak. The credential routing is not touched.