You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn when checkout.ref names an untrusted ref while imported or custom steps run on it (runs branch code on the host) #73080
A common pattern is: a planner job picks a PR branch, checkout.ref: ${{ needs.plan.outputs.branch }}, and a shared toolchain import (steps: - run: ./scripts/setup.sh). That runs the branch's own setup script on the host, outside the sandbox, in the job that later runs the engine with its credential. CodeQL reports it as actions/untrusted-checkout (critical). Nothing in gh-aw warns about it, and the safe pattern isn't documented: leave the checkout on the default branch, let toolchain steps run, then switch branches in the workflow's own steps:.
Implementation plan
Add a compiler warning (in pkg/workflow, alongside the checkout handling in checkout_manager.go). Raise it when checkout.ref is an expression that isn't the default ref (it references needs.*, github.event.*, inputs.*) and the agent job has imported or custom steps:. Message: "[checkout.ref is set to an expression and steps run after it]. [Those steps execute the checked-out ref's code on the host, outside the sandbox]. [Example: keep checkout on the default branch and switch in steps: git checkout -B "$BRANCH" --track "origin/$BRANCH"]".
Docs: in reference/checkout.md and reference/steps-jobs.md, document the agent job's step order and the safe pattern for working on a planner-chosen branch.
Test in pkg/workflow (compiler warning test): warn for checkout.ref: ${{ needs.plan.outputs.branch }} plus an imported steps: file; no warning without steps, or with a literal default-branch ref.
Acceptance criteria
Compiling the pattern above prints the warning, and the docs show the switch-after-steps pattern.
Activity