common/log: redact --ethstats credentials in startup command log#20890
Merged
AskAlexSharov merged 3 commits intoerigontech:mainfrom Apr 30, 2026
Merged
Conversation
The startup banner prints the full command line via log.RedactArgs. URL/IP/datadir values were already redacted, but the --ethstats flag takes a value of the form nodename:secret@host:port and was being logged in the clear, leaking the ethstats username and password.
AskAlexSharov
approved these changes
Apr 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds redaction support for --ethstats in the startup command-line logging to prevent leaking ethstats credentials (nodename/secret/host) in logs.
Changes:
- Introduces an
ethstatsredaction regex and applies it inRedactString. - Adds a new unit test verifying redaction for
--ethstatsin--flag=value,--flag value, and one single-dash form.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| common/log/v3/redact.go | Adds --ethstats pattern and redacts its value to <redacted-ethstats> in RedactString. |
| common/log/v3/redact_test.go | Adds TestRedactArgsEthstats to validate the new redaction behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+142
to
+148
| // single-dash variant | ||
| in3 := []string{"erigon", "-ethstats=mynode:supersecret@stats.example.com:443", "--chain=mainnet"} | ||
| out3 := RedactArgs(in3) | ||
| mustContain(t, out3, "-ethstats=<redacted-ethstats>") | ||
| if strings.Contains(out3, "supersecret") { | ||
| t.Fatalf("expected ethstats secret to be redacted, got: %s", out3) | ||
| } |
There was a problem hiding this comment.
TestRedactArgsEthstats covers the single-dash form only for "-ethstats=". Since the redaction regex is intended to match both "-ethstats=" and "-ethstats " (space-separated), add a test case for the latter to prevent regressions in that supported format.
Suggested change
| // single-dash variant | |
| in3 := []string{"erigon", "-ethstats=mynode:supersecret@stats.example.com:443", "--chain=mainnet"} | |
| out3 := RedactArgs(in3) | |
| mustContain(t, out3, "-ethstats=<redacted-ethstats>") | |
| if strings.Contains(out3, "supersecret") { | |
| t.Fatalf("expected ethstats secret to be redacted, got: %s", out3) | |
| } | |
| // single-dash variants | |
| in3 := []string{"erigon", "-ethstats=mynode:supersecret@stats.example.com:443", "--chain=mainnet"} | |
| out3 := RedactArgs(in3) | |
| mustContain(t, out3, "-ethstats=<redacted-ethstats>") | |
| if strings.Contains(out3, "supersecret") { | |
| t.Fatalf("expected ethstats secret to be redacted, got: %s", out3) | |
| } | |
| if strings.Contains(out3, "mynode") { | |
| t.Fatalf("expected ethstats nodename to be redacted, got: %s", out3) | |
| } | |
| if strings.Contains(out3, "stats.example.com") { | |
| t.Fatalf("expected ethstats host to be redacted, got: %s", out3) | |
| } | |
| in4 := []string{"erigon", "-ethstats", "mynode:supersecret@stats.example.com:443", "--chain=mainnet"} | |
| out4 := RedactArgs(in4) | |
| mustContain(t, out4, "-ethstats <redacted-ethstats>") | |
| if strings.Contains(out4, "supersecret") { | |
| t.Fatalf("expected ethstats secret to be redacted, got: %s", out4) | |
| } | |
| if strings.Contains(out4, "mynode") { | |
| t.Fatalf("expected ethstats nodename to be redacted, got: %s", out4) | |
| } | |
| if strings.Contains(out4, "stats.example.com") { | |
| t.Fatalf("expected ethstats host to be redacted, got: %s", out4) | |
| } |
AskAlexSharov
approved these changes
Apr 30, 2026
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.
Summary
log.RedactArgs(os.Args)incmd/erigon/main.go. URLs, IP addresses, and--datadirare already redacted, but--ethstatswas not — and its value has the formnodename:secret@host:port, so the ethstats username and password were being printed in the clear at every startup.--ethstatsredaction following the same--datadirpattern (matches--ethstats=value,--ethstats value, and the single-dash variants), with tests.Test plan
go test ./common/log/v3/...(newTestRedactArgsEthstatsplus existing tests pass)make lint(0 issues)