-
Notifications
You must be signed in to change notification settings - Fork 38
[code-scanning-fix] Fix unsafe quoting vulnerability in GH_AW_PROJECT_VIEWS #11401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pelikhan
merged 2 commits into
main
from
fix/code-scanning-alert-538-unsafe-quoting-base64-ce1c0eb9e9558c3c
Jan 22, 2026
Merged
[code-scanning-fix] Fix unsafe quoting vulnerability in GH_AW_PROJECT_VIEWS #11401
pelikhan
merged 2 commits into
main
from
fix/code-scanning-alert-538-unsafe-quoting-base64-ce1c0eb9e9558c3c
Jan 22, 2026
Conversation
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
…ection Fixes code scanning alert #538 - Potentially unsafe quoting (go/unsafe-quoting) **Security Fix**: Replace %q string formatting with base64 encoding for JSON data passed via environment variables to eliminate quote-escaping vulnerabilities. **Root Cause**: The previous implementation used Go's %q format specifier to quote JSON data containing project views configuration. While %q provides backslash escaping, it doesn't fully protect against quote injection if the value is used unsafely in downstream shell commands or SQL queries. **Solution**: Encode the JSON data as base64 before passing it via the GH_AW_PROJECT_VIEWS environment variable. Base64 encoding ensures the value contains only alphanumeric characters and safe symbols (+, /, =), completely eliminating the risk of quote-breaking characters. **Impact**: This is a preventive fix - the environment variable is not currently consumed by JavaScript code, so there is no breaking change. When the JavaScript code is implemented to read this variable, it will need to base64-decode the value before parsing as JSON. **Security Best Practice**: Base64 encoding is the most robust solution for passing arbitrary data through environment variables, as recommended by security experts for preventing injection attacks. Related: CWE-78, CWE-89, CWE-94
pelikhan
reviewed
Jan 22, 2026
pkg/workflow/update_project_job.go
Outdated
| // Base64 encoding ensures the value contains no special characters that could break out | ||
| // of quotes in downstream processing (shell commands, SQL queries, etc.) | ||
| viewsBase64 := base64.StdEncoding.EncodeToString(viewsJSON) | ||
| customEnvVars = append(customEnvVars, fmt.Sprintf(" GH_AW_PROJECT_VIEWS: %s\n", viewsBase64)) |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is not a shell script, this is YAML. THERE IS NO SHELL INJECTION. Add a comment to disable codeql.
Contributor
Copilot AI
added a commit
that referenced
this pull request
Jan 22, 2026
…ssion Replace unnecessary base64 encoding with standard %q formatting for GH_AW_PROJECT_VIEWS environment variable. The original security concern was invalid - this code generates YAML environment variable declarations, not shell scripts, so there is no shell injection risk. Added lgtm[go/unsafe-quoting] suppression comment explaining that %q is safe in this context because the value is set as a YAML environment variable, not executed as shell code. Addresses review feedback in #11401. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…#11402) * Initial plan * fix: replace base64 encoding with %q formatting and add CodeQL suppression Replace unnecessary base64 encoding with standard %q formatting for GH_AW_PROJECT_VIEWS environment variable. The original security concern was invalid - this code generates YAML environment variable declarations, not shell scripts, so there is no shell injection risk. Added lgtm[go/unsafe-quoting] suppression comment explaining that %q is safe in this context because the value is set as a YAML environment variable, not executed as shell code. Addresses review feedback in #11401. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
12 tasks
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: Potentially Unsafe Quoting
Alert Number: #538
Severity: Critical
Rule: go/unsafe-quoting
CWE: CWE-78, CWE-89, CWE-94
Vulnerability Description
The code was using Go's
%qformat specifier to quote JSON data containing project views configuration before passing it via theGH_AW_PROJECT_VIEWSenvironment variable. While%qprovides backslash escaping, it doesn't fully protect against quote injection attacks if the value is later used in shell commands, SQL queries, or other contexts where quotes have special meaning.CodeQL flagged this as a critical security issue because if the JSON value contains a single quote, it could break out of the enclosing quotes in downstream processing, potentially enabling command injection or SQL injection attacks.
Location
pkg/workflow/update_project_job.goFix Applied
Replaced
%qstring formatting with base64 encoding for the JSON data. This approach:+,/,=), making it impossible for special characters like quotes to break out of string contextsChanges Made:
encoding/base64importfmt.Sprintf("... %q\n", string(viewsJSON))with base64 encodingBefore:
After:
Security Best Practices
This fix implements defense-in-depth security by:
Testing Considerations
GH_AW_PROJECT_VIEWSenvironment variable is not currently consumed by JavaScript code, so this change has no immediate impactBuffer.from(process.env.GH_AW_PROJECT_VIEWS, 'base64').toString()before parsing as JSONReferences
Automated by: Code Scanning Fixer Workflow
Run ID: 21267994348