process: redact secret-bearing arguments in List output - #642
Open
sfc-gh-ikryvanos wants to merge 1 commit into
Open
process: redact secret-bearing arguments in List output#642sfc-gh-ikryvanos wants to merge 1 commit into
sfc-gh-ikryvanos wants to merge 1 commit into
Conversation
Process command lines frequently contain credentials passed as flags or environment assignments (passwords, tokens, keys). List now masks the values of secret-like arguments by default via an overridable redactor, so deployments that need the raw command line can restore it.
Comment on lines
+126
to
+138
| // secretArgPattern matches the value of a command-line flag or environment | ||
| // assignment whose name suggests it carries a credential (password, token, key, | ||
| // etc.). The name and delimiter are captured so they can be preserved while the | ||
| // value is masked. | ||
| var secretArgPattern = regexp.MustCompile(`(?i)(-{1,2}(?:password|passwd|pwd|token|secret|api[-_]?key|access[-_]?key|auth[-_]?token|credential|private[-_]?key)[=\s]+|[A-Za-z0-9_]*(?:password|passwd|secret|token|apikey|api_key|credential)[A-Za-z0-9_]*=)(\S+)`) | ||
|
|
||
| // redactProcessArgs masks values that look like secrets in a process command | ||
| // line. Command-line arguments frequently contain credentials, so List redacts | ||
| // them by default. Deployments that need the raw command line can override this | ||
| // (for example, set it to a function that returns its input unchanged). | ||
| var redactProcessArgs = func(cmd string) string { | ||
| return secretArgPattern.ReplaceAllString(cmd, "${1}REDACTED") | ||
| } |
There was a problem hiding this comment.
🟠 MEDIUM · Secret-redaction regex incomplete — leaks credentials in JSON/nested/no-delimiter forms and short-value tokens · CWE-532
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.
Process command lines frequently contain credentials passed as flags or environment assignments (passwords, tokens, keys). List now masks the values of secret-like arguments by default via an overridable redactor, so deployments that need the raw command line can restore it.