Skip to content

process: redact secret-bearing arguments in List output - #642

Open
sfc-gh-ikryvanos wants to merge 1 commit into
mainfrom
fix/process-list-redact-args
Open

process: redact secret-bearing arguments in List output#642
sfc-gh-ikryvanos wants to merge 1 commit into
mainfrom
fix/process-list-redact-args

Conversation

@sfc-gh-ikryvanos

Copy link
Copy Markdown
Collaborator

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.

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")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · Secret-redaction regex incomplete — leaks credentials in JSON/nested/no-delimiter forms and short-value tokens · CWE-532

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