Redact private key material from SSH error messages - #38543
Closed
SebTardif wants to merge 2 commits into
Closed
Conversation
Remove private key content, certificate content, and parsed key structs from error messages in signCertWithPrivateKey(). These values were formatted with %q into error strings that appear in terminal output and CI logs, exposing credential material. The underlying crypto library error (preserved via %s) already describes the failure cause (malformed PEM, unsupported algorithm, etc.), so no diagnostic information is lost. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Contributor
|
@SebTardif Please see our Contributing.md, particularly the sections Proposing a Change and AI Usage. One of our requirements is disclosure of AI usage. Thanks for this submission. |
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Contributor
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
signCertWithPrivateKey()in the SSH communicator formats private keycontent, certificate content, and parsed key structs into error messages
using
%q. These error strings propagate to terminal output and CI logs(GitHub Actions, Jenkins, etc.), exposing credential material to anyone
with log access.
This commit removes the sensitive values from the four
fmt.Errorfcallsin the function. The underlying
golang.org/x/crypto/ssherror (stillincluded via
%s) already describes the failure cause (malformed PEM,unsupported algorithm, key/cert type mismatch), so no diagnostic
information is lost. The four distinct error prefixes still identify
which step failed.
The sibling function
readPrivateKey()was already safe (it only formatserr, not the key content).Related redaction work in this repo:
Similar fix in other projects:
Target Release
1.16.x
Rollback Plan
Changes to Security Controls
Yes. This change prevents private key material from being exposed in error
messages that appear in terminal output and CI/CD logs.
CHANGELOG entry