[code-scanning-fix] Fix go/unsafe-quoting: Use base64 encoding for project views configuration #11432
+4
−5
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: Potentially Unsafe Quoting in Project Views Configuration
Alert Number: #538
Severity: Critical
Rule: go/unsafe-quoting
CWE: CWE-78 (OS Command Injection), CWE-89 (SQL Injection), CWE-94 (Code Injection)
Vulnerability Description
CodeQL identified a critical security issue where JSON data containing project views configuration was being directly embedded into a YAML environment variable declaration using Go's
%qformat specifier. While%qescapes characters for Go string literals, it doesn't eliminate the risk of quote-based injection attacks when the resulting YAML is processed.The vulnerable code constructed a quoted string from potentially untrusted JSON data:
If the JSON contained certain quote characters, they could potentially break out of the enclosing quotes and alter the structure of the YAML configuration, leading to injection vulnerabilities.
Location
Fix Applied
The fix uses base64 encoding to safely pass JSON data through YAML without any quoting concerns. Base64 encoding eliminates all special characters that could break YAML syntax.
Changes Made:
encoding/base64importGH_AW_PROJECT_VIEWStoGH_AW_PROJECT_VIEWS_BASE64to indicate the encodingCode Change:
Security Best Practices
This fix follows several security best practices:
GH_AW_PROJECT_VIEWS_BASE64makes it clear that consumers must decode the valueTesting Considerations
Note: The environment variable
GH_AW_PROJECT_VIEWS_BASE64(or the previousGH_AW_PROJECT_VIEWS) is not currently consumed by any JavaScript code in the repository. This fix is preventative.If this variable is used in the future, the consuming code should:
process.env.GH_AW_PROJECT_VIEWS_BASE64Buffer.from(viewsBase64, 'base64').toString('utf-8')JSON.parse(decodedString)No breaking changes: Since the variable is not currently used, this change has no impact on existing functionality.
Why Previous Fixes Failed
This is the 7th attempt to fix alert #538. Previous attempts likely failed because:
This fix takes a different approach by eliminating the quoting problem entirely through base64 encoding, which is a proven secure method for passing binary or structured data through text-based configuration formats.
Automated by: Code Scanning Fixer Workflow
Run ID: 21272238432
Workflow: Alert #538 has been open since 2026-01-15 and had 6 previous fix attempts