Conversation
| fmt.Fprint(ul.Writer, msg) | ||
| ul.log.Info(msg) | ||
| fmt.Fprint(ul.Writer, s) | ||
| ul.log.Info(strings.TrimSpace(s)) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, sensitive data (subnetAuthKeys) should be obfuscated or omitted entirely before being logged. This can be achieved by replacing the logging of subnetAuthKeys with a sanitized or masked version of the data. For example, sensitive keys can be replaced with a hash or a truncated version that does not reveal the full key.
The changes will be made in both cmd/blockchaincmd/change_owner.go and pkg/ux/output.go:
- In
cmd/blockchaincmd/change_owner.go, sanitize or masksubnetAuthKeysbefore passing it toux.Logger.PrintToUser. - In
pkg/ux/output.go, ensure that thePrintToUsermethod does not log sensitive data in clear text.
| @@ -58,3 +58,3 @@ | ||
| fmt.Fprint(ul.Writer, s) | ||
| ul.log.Info(strings.TrimSpace(s)) | ||
| ul.log.Info(strings.TrimSpace(utils.SanitizeLogMessage(s))) | ||
| } else { |
| @@ -123,3 +123,4 @@ | ||
| } | ||
| ux.Logger.PrintToUser("Your auth keys for add validator tx creation: %s", subnetAuthKeys) | ||
| maskedKeys := utils.MaskSensitiveKeys(subnetAuthKeys) | ||
| ux.Logger.PrintToUser("Your auth keys for add validator tx creation: %s", maskedKeys) | ||
|
|
| ul.log.Info(strings.TrimSpace(s)) | ||
| } else { | ||
| fmt.Print(msg) | ||
| fmt.Print(s) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Why this should be merged
Currently, prompt options and tables and not included in the main log, which makes it difficult
to fully check what were the inputs and the processing results.
How this works
How this was tested
How is this documented