[security-fix] Security Fix: Prevent logging of secret key names in validation errors (Alert #71) #7240
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: Prevent Clear-Text Logging of Secret Key Names
Alert Number: #71
Severity: High (Error)
Rule: go/clear-text-logging
CWE: CWE-312, CWE-315, CWE-359
Vulnerability Description
CodeQL detected a security vulnerability where sensitive data from the
secretKeysvariable flows through error messages into JSON output logs atpkg/cli/compile_orchestrator.go:586.The data flow path:
secretKeysvariable inpkg/workflow/jobs.go:328validateSecretsExpression()inpkg/workflow/compiler_jobs.go:389"jobs.secrets.%s must be a GitHub Actions expression..."ValidationError.Messageinpkg/cli/compile_orchestrator.govalidationResultsis marshaled to JSON and printed to stdout at line 586While actual secret VALUES were never logged, exposing secret KEY NAMES is a security issue as it reveals information about an organization's security infrastructure, authentication mechanisms, and system architecture.
Previous Fix Attempts
PR #7224 removed key names from log statements but NOT from error messages. This PR addresses the root cause by removing key names from the error messages themselves, preventing them from flowing to JSON output.
Fix Applied
Modified
pkg/workflow/secrets_validation.go:%sformat specifier andkeyparameter from the error message returned byvalidateSecretsExpression()"jobs.secrets.%s must be a GitHub Actions expression..."to:"invalid secrets expression: must be a GitHub Actions expression..."Before:
After:
Updated
pkg/workflow/secrets_validation_test.go:Security Best Practices Applied
Testing Considerations
✅ All tests pass:
TestValidateSecretsExpression- Pattern matching and validation logic unchangedTestValidateSecretsExpressionErrorMessages- Verifies key names are NOT in error messagesTestValidateSecretsExpressionWithDifferentKeys- Verifies security fix across various key namesTestSecretsValidationEdgeCases- Edge cases handled correctlyTestJobsSecretsValidation- End-to-end compilation with secrets validation✅ Error messages remain informative: Users still see helpful guidance about the correct format
✅ No breaking changes: The fix only affects error message content, not functionality or API
Run tests with:
Impact
This is a security-only fix with no functional changes:
The fix prevents exposure of organizational security infrastructure details while maintaining all existing functionality.
Why This Approach is Correct
Unlike previous attempts that tried to sanitize error messages after they were created, this fix removes the sensitive data at the source - the error message format string itself. This ensures that no matter how the error propagates through the system, the key name will never be logged.
References
🤖 Generated with [Claude Code]((redacted)
Co-Authored-By: Claude Sonnet 4.5 (noreply@anthropic.com)