[security-fix] Fix clear-text logging vulnerability by removing secret key parameter from validation #7289
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.
Security Fix: Clear-text Logging of Sensitive Information
Alert Number: #71
Severity: High
Rule: go/clear-text-logging
Location: pkg/cli/compile_orchestrator.go:586
Vulnerability Description
CodeQL detected a data flow of sensitive information (secret key names) from the
secretKeysvariable through thevalidateSecretsExpressionfunction to JSON output at line 586 ofcompile_orchestrator.go. Even though the error message itself did not include the key name, CodeQL flagged the data flow because thekeyparameter was being passed through the validation function, creating a potential path for sensitive information to reach logging or output systems.Root Cause
The
validateSecretsExpression(key, value string)function accepted the secret key name as a parameter, even though it was not used in error messages. This created a data flow path that CodeQL detected as a security risk, as the sensitivekeyvariable was flowing through the function that could potentially expose it in error outputs.Fix Applied
Removed the
keyparameter entirely from thevalidateSecretsExpressionfunction to break the data flow path and prevent CodeQL from detecting sensitive information flowing to error messages or logs.Changes Made
pkg/workflow/secrets_validation.go
validateSecretsExpression(key, value string)tovalidateSecretsExpression(value string)keyparameterpkg/workflow/compiler_jobs.go
validateSecretsExpressionto only pass thevalueparameterpkg/workflow/secrets_validation_test.go
keyparameter from function callspkg/workflow/jobs_secrets_validation_test.go
keyparameterSecurity Best Practices Applied
keyparameter, we minimize the flow of sensitive data through the codebaseTesting
All existing tests pass with the updated function signature:
Impact
References