Conversation
This commit fixes CodeQL alert #10 (go/unsafe-quoting) in pkg/workflow/redact_secrets.go by properly escaping single quotes and backslashes before embedding secret references in YAML strings. **Issue**: JSON values containing single quotes could break out of enclosing quotes, potentially leading to command/SQL/code injection (CWE-78, CWE-89, CWE-94). **Fix**: Added escapeSingleQuote() helper function that: - Escapes backslashes first to prevent interference - Escapes single quotes to prevent breaking out of quoted strings - Applied escaping to all secret references before embedding in YAML **Security Impact**: Prevents potential injection attacks when secret names contain special characters that could manipulate the generated YAML structure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
Agentic Changeset Generator triggered by this pull request |
Added changeset documenting the patch-level security fix that prevents injection vulnerabilities in YAML generation for secret redaction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
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