[security-fix] Security Fix: Prevent injection in secret redaction YAML generation #1517
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 Injection in Secret Redaction YAML Generation
Alert Number: #10
Severity: Critical
Rule: go/unsafe-quoting
File:
pkg/workflow/redact_secrets.go:70Vulnerability Description
CodeQL identified a critical security vulnerability where JSON values containing single quotes could break out of enclosing quotes when embedded in YAML strings. This potentially unsafe quoting pattern could lead to:
The vulnerability occurred in the
generateSecretRedactionStepfunction where secret references were embedded directly into YAML strings without proper escaping:If a secret name contained a single quote (e.g.,
SECRET'NAME), it would break out of the enclosing quotes and could potentially inject malicious YAML content.Fix Applied
Added a new
escapeSingleQuote()helper function that properly sanitizes data before embedding it in single-quoted YAML strings:Applied this escaping to all secret references before embedding them in the YAML:
Security Best Practices
Testing Considerations
References
🤖 Generated with Claude Code