[Secrets] CLI set/rotate take the secret value on the command line (history, process list, config parse leak) #35
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the scadaproj#15 shared-library review (
code-reviews/Secrets/findings.md, Secrets-017), verified at91fb2b4. Update the finding's Resolution row when fixed.ZB.MOM.WW.Secrets/src/ZB.MOM.WW.Secrets.Cli/Program.cs:21(values consumed at:57,:65)Description
The headless verbs take the secret value as a positional argument:
set <name> <value>androtate <name> <value>(lines 57 and 65). There is no stdin or masked-prompt alternative.The
rewrap-allpath deliberately refuses literal key material, "which would be echoed/logged" (lines 91–92). Secret values get no such protection: they land in shell history and are visible in the process list (ps, or Windows process command lines in EDR telemetry) to any local user for the duration of the run.Host.CreateApplicationBuilder(args)(line 21) also feeds the same argv into the command-line configuration provider:=becomes a configuration key/value pair.-and containing=throws an unhandledFormatException. That happens before the verb'scatchis set up, and the exception message contains the whole argument.Failure scenario
secret set db/pw "-p=Hunter2Secret", run from a throwaway probe (not committed), prints:The secret goes to stderr, which CI logs, deploy-script transcripts and the WinRM output capture all retain. The CLI exits with an unhandled crash rather than its usage code.
Even without the crash, every
secret setleaves the plaintext in~/.zsh_history, PSReadLine history, or the equivalent.Recommendation
-or--value-stdin) or a masked prompt when stdin is a TTY, and document that as the preferred form.Host.CreateApplicationBuilder(new HostApplicationBuilderSettings { Args = [] }), or strip the verb arguments, so argv is never parsed as configuration.Resolution
Unresolved.
Fixed on main 0b610b4 (Secrets-017 → Resolved):
set/rotate <name>read the value from piped stdin,-/--value-stdin, or a masked prompt entered twice; the positional value still works with a warning. The CLI no longer feeds command-line args into configuration (old code printed the secret inside a FormatException for-p=…). CLI behaviour changes: no config overrides from the command line (use env vars); startup failure printssecret: startup failed: <message>and exits 1; an unexpected argument is reported by position, not echoed. Evidence: Secrets solution (5 test projects) all pass — Core 246 (1 DPAPI skip), SqlServer 60 (16 live-SQL skips), Akka 44, Grpc 196, Ui 20; each regression test fails with its fix removed. Ships in Secrets 0.6.6 (unpublished).