Replace base64 encoding with %q formatting and add CodeQL suppression#11402
Merged
pelikhan merged 2 commits intofix/code-scanning-alert-538-unsafe-quoting-base64-ce1c0eb9e9558c3cfrom Jan 22, 2026
Conversation
…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>
Copilot
AI
changed the title
[WIP] Fix unsafe quoting vulnerability in GH_AW_PROJECT_VIEWS
Replace base64 encoding with %q formatting and add CodeQL suppression
Jan 22, 2026
This was referenced Jan 22, 2026
pelikhan
approved these changes
Jan 22, 2026
e47c836
into
fix/code-scanning-alert-538-unsafe-quoting-base64-ce1c0eb9e9558c3c
61 checks passed
pelikhan
added a commit
that referenced
this pull request
Jan 22, 2026
…_VIEWS (#11401) * fix: use base64 encoding for GH_AW_PROJECT_VIEWS to prevent quote injection 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 * Replace base64 encoding with %q formatting and add CodeQL suppression (#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> --------- Co-authored-by: GitHub Actions Bot <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.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.
The base64 encoding added to fix CodeQL alert #538 was unnecessary. This code generates YAML environment variable declarations, not shell commands—there's no shell injection risk.
Changes
%qformatting: Replaced base64 encoding with standard Go string quoting, matching the pattern used elsewhere (e.g.,GH_AW_ALLOWED_REASONSinadd_comment.go)lgtm[go/unsafe-quoting]explaining that the output is YAML environment variable syntax, not executable shell codeContext
The
customEnvVarsstrings are directly appended to GitHub Actions YAML:The JavaScript runtime reads this as
process.env.GH_AW_PROJECT_VIEWS—no shell execution occurs.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.