Skip to content

cmd: redact header flag values in config log#4523

Merged
aly-obol merged 2 commits into
mainfrom
fix/redact-header-values
May 15, 2026
Merged

cmd: redact header flag values in config log#4523
aly-obol merged 2 commits into
mainfrom
fix/redact-header-values

Conversation

@aly-obol
Copy link
Copy Markdown
Contributor

@aly-obol aly-obol commented May 15, 2026

Summary

  • The "Parsed config" log line dumps all flag values verbatim. Flags containing "header" (beacon-node-headers, otlp-headers) were not redacted, leaking authentication credentials in logs.
  • Add a header-aware redaction path to redact() that preserves the header key for debuggability while masking the value (e.g., Authorization=xxxxx).
  • Also handles slice flags (multiple headers) via the existing flagsToLogFields loop.

Description

The redact() function in cmd/cmd.go already handled auth-token flags (full redaction) and address flags (URL password redaction), but did not cover header flags. When --beacon-node-headers=Authorization=Basic <token> was set, the full cleartext value appeared in the startup log. This led to a real credential exposure when a log file was accidentally committed to a public repo.

The fix adds a strings.Contains(flag, "header") check that delegates to redactHeaderValue(), which splits on the first = and replaces the value with xxxxx while keeping the key visible for debugging.

Test plan

  • TestRedact — new subcases for beacon-node-headers, otlp-headers, and a header without a value
  • TestFlagsToLogFieldsRedactsHeaders — verifies slice values are redacted when processed through flagsToLogFields
  • All existing TestRedact and TestFlagsToLogFields cases still pass

category: bug
ticket: none

The "Parsed config" log line dumps all flag values verbatim. Flags containing "header" (beacon-node-headers, otlp-headers) were not redacted, leaking authentication credentials in logs.

Add a header-aware redaction path that preserves the header key for debuggability while masking the value (e.g., "Authorization=xxxxx").

category: bug
ticket: none
@aly-obol aly-obol requested a review from a team May 15, 2026 03:11
@aly-obol aly-obol enabled auto-merge (squash) May 15, 2026 03:11
@aly-obol aly-obol force-pushed the fix/redact-header-values branch from 71a657e to 03d8c7f Compare May 15, 2026 03:20
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.06%. Comparing base (764e780) to head (b7a4a05).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4523      +/-   ##
==========================================
+ Coverage   57.05%   57.06%   +0.01%     
==========================================
  Files         245      245              
  Lines       32964    32971       +7     
==========================================
+ Hits        18806    18816      +10     
+ Misses      11782    11777       -5     
- Partials     2376     2378       +2     

☔ View full report in Codecov by Sentry.
📢 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.

Removes nolint directives that caused a nolintlint/revive catch-22 by eliminating the fmt.Sprintf calls entirely.

category: refactor
ticket: none
@sonarqubecloud
Copy link
Copy Markdown

@aly-obol aly-obol merged commit 7391c21 into main May 15, 2026
10 of 13 checks passed
@aly-obol aly-obol deleted the fix/redact-header-values branch May 15, 2026 05:36
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.

2 participants