app/stacksnipe: redact secrets in exported command lines - #4688
Conversation
The stack sniping collector read the full command line of every detected validator client and exported it verbatim, both as the cli_parameters label of the app_validator_stack_params gauge served on the monitoring endpoint, and as a field of a debug log line. Validator client command lines routinely carry secret material, for example keystore passwords, the paths of files holding them, and keymanager bearer tokens. Exporting them unmodified pushes that material into the metrics and log planes, whose readers and retention are usually much broader than the process table it came from. Redact the values of flags whose names look sensitive (auth, jwt, key, passphrase, password, secret, token) before the command line is logged or handed to the metrics callback. Both the "--flag value" and the "--flag=value" forms are handled, and flag names are preserved so the telemetry stays useful. A /proc cmdline is NUL separated, so redaction normally operates per argument; if the whole command line ever arrives as a single blob it is split on whitespace first, so redaction fails safe rather than passing the blob through untouched. Also warn at startup when --proc-directory is set, and note the disclosure tradeoff in the flag's help text, so the behaviour is not a surprise. The feature remains disabled by default.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4688 +/- ##
==========================================
+ Coverage 65.38% 65.48% +0.09%
==========================================
Files 247 247
Lines 29983 30057 +74
==========================================
+ Hits 19605 19682 +77
+ Misses 10377 10374 -3
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Two command-line parsing edge cases can still expose sensitive values.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Redacts sensitive validator-client command-line values before exporting them to logs and metrics.
Changes:
- Adds sensitive-flag redaction for command lines.
- Warns operators when stack sniping is enabled.
- Documents and tests the disclosure behavior.
File summaries
| File | Description |
|---|---|
app/stacksnipe/stacksnipe.go |
Implements redaction and startup warning. |
app/stacksnipe/stacksnipe_test.go |
Tests redaction behavior. |
cmd/run.go |
Updates flag help text. |
docs/configuration.md |
Regenerates configuration documentation. |
Review details
Suppressed comments (1)
app/stacksnipe/stacksnipe.go:194
- A sensitive flag value may legitimately begin with
-(for example,--password -hunter2). This branch treats that value as another flag and can append it unchanged, leaking it to both telemetry sinks. Since option arity is unknown here, resolve the ambiguity toward redaction while still tracking a subsequent bare sensitive flag.
if redactNext {
redactNext = false
// A flag rather than a value means the previous flag was a boolean, keep walking.
if !strings.HasPrefix(arg, "-") {
redacted = append(redacted, redactedValue)
continue
}
}
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
641b932 to
9aebcf9
Compare
|
There was a problem hiding this comment.
🟡 Changes recommended
Ambiguous double-dash values can leak secrets, and the promised startup warning uses INFO severity.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Balanced



Problem
The stack sniping collector reads the full command line of every detected validator client and exports it verbatim in two places:
cli_parameterslabel of theapp_validator_stack_paramsgauge, served on the monitoring endpointDetected stack componentdebug log lineValidator client command lines routinely carry secret material: keystore passwords, the paths of the files holding them, and keymanager bearer tokens, among others. Exporting them unmodified moves that material into the metrics and log planes, whose readers and retention are typically much broader than the process table it was read from.
Change
Redact the values of flags whose names look sensitive (
auth,jwt,key,passphrase,password,secret,token) before the command line is logged or handed to the metrics callback:--flag valueand the--flag=valueforms are handled<redacted>/proccmdline is NUL separated, so redaction normally operates per argument. If the whole command line ever arrives as a single blob, it is split on whitespace first, so redaction fails safe rather than passing the blob through untouchedAlso:
INFOline at startup when--proc-directoryis set, so the disclosure tradeoff is visible to operatorsdocs/configuration.md)The feature remains disabled by default;
--proc-directorystill defaults to empty.Testing
go test ./app/stacksnipe/passes, with two new subtests: one asserting no secret material survives export from a realistic NUL separated cmdline (while non-sensitive flags and values are untouched), and one covering the unsplit-blob fallbackgo test ./cmd -run=TestConfigReferencepasses, confirmingdocs/configuration.mdmatches the updated flag helpgofmtcleancategory: bug
ticket: none