[code-scanning-fix] Fix go/unsafe-quoting: Use base64 encoding for project views #11411
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: Unsafe Quoting in Project Views Configuration
Alert Number: #538
Severity: Critical
Rule: go/unsafe-quoting
CWE: CWE-78, CWE-89, CWE-94
Vulnerability Description
CodeQL identified a potential unsafe quoting vulnerability in
pkg/workflow/update_project_job.goat line 51. The code was using the%qformat specifier to embed JSON data containing project views configuration into a YAML environment variable. While%qprovides proper Go string escaping, it doesn't protect against potential injection if the value is later misused in shell contexts with single quotes, as JSON strings can contain unescaped single quotes.Location
pkg/workflow/update_project_job.gobuildUpdateProjectJobFix Applied
Replaced the
%qformat specifier with base64 encoding for theGH_AW_PROJECT_VIEWSenvironment variable. Base64 encoding ensures that the value contains only alphanumeric characters plus+,/, and=, completely eliminating any possibility of quote-based injection attacks.Changes Made:
update_project_job.goupdate_project_test.go:TestUpdateProjectJob_ViewsConfigurationBase64: Tests base64 encoding with various special characters including single quotes, double quotes, and backslashesTestUpdateProjectJob_Base64EncodingPreventsSQLInjection: Security test verifying that malicious input (SQL injection, command injection, variable expansion) is safely encodedBefore:
After:
Security Best Practices
This fix implements defense-in-depth security by:
Testing Considerations
The comprehensive test suite validates:
All tests pass, demonstrating that the fix properly addresses the security vulnerability while maintaining correct functionality.
Automated by: Code Scanning Fixer Workflow
Run ID: 21268790203