Skip to content

app/stacksnipe: redact secrets in exported command lines - #4688

Open
aly-obol wants to merge 1 commit into
mainfrom
fix/stacksnipe-redact-secret-flag-values
Open

app/stacksnipe: redact secrets in exported command lines#4688
aly-obol wants to merge 1 commit into
mainfrom
fix/stacksnipe-redact-secret-flag-values

Conversation

@aly-obol

@aly-obol aly-obol commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Problem

The stack sniping collector reads the full command line of every detected validator client and exports it verbatim in two places:

  • as the cli_parameters label of the app_validator_stack_params gauge, served on the monitoring endpoint
  • as a field of the Detected stack component debug log line

Validator 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:

  • both the --flag value and the --flag=value forms are handled
  • flag names are preserved, so the telemetry keeps its diagnostic value; only values are replaced with <redacted>
  • 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:

  • log a WARN at startup when --proc-directory is set, so the disclosure tradeoff is visible to operators
  • note the same tradeoff in the flag's help text (and the regenerated docs/configuration.md)

The feature remains disabled by default; --proc-directory still 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 fallback
  • go test ./cmd -run=TestConfigReference passes, confirming docs/configuration.md matches the updated flag help
  • gofmt clean

category: bug
ticket: none

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.
@aly-obol
aly-obol requested a review from a team September 7, 2026 18:53
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@aly-obol
aly-obol enabled auto-merge (squash) September 7, 2026 18:53
@aly-obol aly-obol changed the title app/stacksnipe: redact secret flag values from exported command lines app/stacksnipe: redact secrets in exported command lines Sep 7, 2026
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.49%. Comparing base (071b0d0) to head (14b160f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4688      +/-   ##
==========================================
+ Coverage   65.38%   65.49%   +0.10%     
==========================================
  Files         247      247              
  Lines       29983    30070      +87     
==========================================
+ Hits        19605    19693      +88     
+ Misses      10377    10376       -1     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant