Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

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

  • Reverted to %q formatting: Replaced base64 encoding with standard Go string quoting, matching the pattern used elsewhere (e.g., GH_AW_ALLOWED_REASONS in add_comment.go)
  • Added CodeQL suppression: Annotated with lgtm[go/unsafe-quoting] explaining that the output is YAML environment variable syntax, not executable shell code

Context

The customEnvVars strings are directly appended to GitHub Actions YAML:

env:
  GH_AW_PROJECT_VIEWS: "[{\"name\":\"Status\"}]"  # YAML env var, not shell

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.

…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
Copilot AI requested a review from pelikhan January 22, 2026 23:22
@pelikhan pelikhan marked this pull request as ready for review January 22, 2026 23:23
@pelikhan pelikhan merged commit e47c836 into fix/code-scanning-alert-538-unsafe-quoting-base64-ce1c0eb9e9558c3c Jan 22, 2026
61 checks passed
@pelikhan pelikhan deleted the copilot/sub-pr-11401 branch January 22, 2026 23:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants