Visitar URL original
Harden composite action against shell expression and env-file injection by Copilot · Pull Request #66 · ko-build/setup-ko · GitHub
Skip to content

Harden composite action against shell expression and env-file injection - #66

Merged
imjasonh merged 1 commit into
mainfrom
copilot/address-findings-report
Jun 26, 2026
Merged

imjasonh merged 1 commit into
mainfrom
copilot/address-findings-report

Conversation

Copilot AI commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

The hardening report identified high-severity injection risks in action.yml: GitHub expressions were interpolated directly inside shell commands, and repository-derived data was written to $GITHUB_ENV without newline sanitization. This change scopes untrusted values to step environment variables and sanitizes env-file output paths.

  • Expression isolation in run:

    • Moved runtime expressions (inputs.*, github.*, runner.*) into env: and referenced only shell variables in the script.
    • Eliminates direct ${{ ... }} interpolation inside command execution paths.
  • Env-file injection mitigation

    • Sanitizes repository-derived values with tr -d '\n\r' before composing KO_DOCKER_REPO.
    • Writes only sanitized content to $GITHUB_ENV.
  • Minor command safety cleanup

    • Quoted release download URL expansion for safer shell handling.
env:
  KO_VERSION: ${{ inputs.version }}
  USE_SUDO: ${{ inputs.use-sudo }}
  GH_TOKEN: ${{ github.token }}
  RUNNER_OS: ${{ runner.os }}
  RUNNER_ARCH: ${{ runner.arch }}
  GITHUB_REPOSITORY: ${{ github.repository }}
run: |
  repo=$(printf '%s' "${GITHUB_REPOSITORY}" | tr -d '\n\r' | tr '[:upper:]' '[:lower:]')
  ko_docker_repo=$(printf 'ghcr.io/%s' "${repo}")
  echo "KO_DOCKER_REPO=${ko_docker_repo}" >> "${GITHUB_ENV}"

Copilot AI changed the title Harden action.yml against shell and env injection Harden composite action against shell expression and env-file injection Jun 26, 2026
Copilot AI requested a review from imjasonh June 26, 2026 22:34
@imjasonh
imjasonh marked this pull request as ready for review June 26, 2026 22:38
@imjasonh
imjasonh enabled auto-merge June 26, 2026 22:38
@imjasonh

Copy link
Copy Markdown
Member

@imjasonh
imjasonh merged commit 61b4d1d into main Jun 26, 2026
3 of 6 checks passed
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.

3 participants