Redact KMS URI secrets from plugin error output#1669
Open
TicketWindowSeat wants to merge 1 commit into
Open
Conversation
When a step-kms-plugin subprocess fails, exitError embeds the full command line in the returned error via cmd.String(). If the KMS URI carries an inline credential, the secret is printed in cleartext: error creating certificate request: command ".../step-kms-plugin sign --format base64 --kms yubikey:serial=NNN;pin-value=<PIN> yubikey:slot-id=9c" failed with: Error: command failed: smart card error 6982: ... pin-value is the documented way to supply the PIN non-interactively, and this error text is exactly what users paste into terminals, CI logs, and public bug reports. Redact the values of the three KMS URI attributes that carry credentials -- pin-value (yubikey, pkcs11, capi), management-key (yubikey), and client-secret (azurekms) -- from both the echoed command line and the plugin's passed-through stderr, keeping the rest of the command intact for debugging. The stderr is scrubbed too because step-kms-plugin echoes the URI itself on some error paths (e.g. "%s does not implement Attester"). Fixes smallstep#1668
|
|
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.
Name of feature:
Redact KMS URI secrets (
pin-value,management-key,client-secret) from the errorprinted when a
step-kms-pluginsubprocess fails.Pain or issue this feature alleviates:
When the plugin subprocess fails,
stepprints the full command line it ran — includingthe KMS URI with any inline credential. A real ceremony on Windows (step 0.30.6,
step-kms-plugin 0.17.0, YubiKey 4) produced:
pin-value=is the documented way to supply the PIN non-interactively, so using thefeature as designed puts the secret on stderr on any failure. From there it lands in
console scrollback, session transcripts, CI logs — and GitHub issues, because pasting
exactly this error text is what users do when reporting bugs.
Why is this important to the project (if not answered above):
trackers and search indexes.
and is kept — only the values of the three credential-carrying attributes across all
KMS schemes (
pin-valuefor yubikey/pkcs11/capi,management-keyfor yubikey,client-secretfor azurekms) are replaced withREDACTED. The redaction runs overthe whole rendered command line, so it also covers a secret that reaches the plugin
as a positional argument —
--attestation-uriis passed as both the--kmsvalueand the positional key argument (
utils/cautils/acmeutils.go).The plugin's own stderr is scrubbed with the same expression before being embedded,
because step-kms-plugin echoes the URI itself on some paths (e.g.
%s does not implement Attesterincmd/attest.go), andgo.step.sm/crypto'suri.Parseerrors embed the raw URI as well.Redaction stops the value at the next URI delimiter (
;,&,?), whitespace, or adouble quote, so the surrounding command line and any Go-quoted error prose stay intact.
One residual limitation, inherent to string-level redaction: a value containing a raw,
non-percent-encoded space is only redacted up to that space. Such a URI is malformed
(a well-formed URI percent-encodes the space, which redacts fully); the fix trades a
rare partial leak for keeping the rest of the command readable, rather than
over-redacting every failure message.
Is there documentation on how to use this feature? If so, where?
No behavior to document: error output now shows
pin-value=REDACTEDin place of thesecret; everything else is unchanged.
In what environments or workflows is this feature supported?
Redact KMS URI secrets (
pin-value,management-key,client-secret) from the errorprinted when a
step-kms-pluginsubprocess fails.In what environments or workflows is this feature explicitly NOT supported (if any)?
All platforms and all KMS schemes; the redaction is plain string processing in
internal/cryptoutilwith hardware-free unit tests (the package's first).Supporting links/other PRs/issues:
💔Thank you!