Skip to content

Preview setup leaves a pull request head reached through a shell variable unverified instead of refusing it #3992

Open

Description

@dawsontoth

harper preview setup checks the preview workflow for a token-holding job that checks out the pull request's head. Since #3807, a head value that reaches a git command through the shell is reported as unverified rather than refused. That covers a value through an assignment (REF="$SHA", REF=${{ github.event.pull_request.head.sha }}), read, for or printf -v, and an env: value that some script in the job also names. The operator can pass allow_unverified=true to go ahead.

That is deliberate, per Kris's review of #3807. Which value a command uses depends on the step's shell, the order of assignments, and which earlier step wrote GITHUB_ENV. Treating any of those as proof refused safe workflows with an error that cannot be acknowledged. But it also means a workflow that plainly checks out the head through a binding gets an overridable warning, not a refusal.

The same rule is broad in the other direction: any mention of the variable's name in a script that is not a read of it, such as # verify SHA or echo "SHA is $SHA", counts as possibly setting it. That turns a head an env: value names outright into an unverified entry. It is broad on purpose, since shell has more ways to set a variable (read, for, printf -v, a GITHUB_ENV write) than a list would hold, and a missed one would be a refusal the operator cannot get past.

Possible improvement: refuse a binding whose scope and order setup can establish. For example, the only assignment of the variable in the same step, at top level, before the git line, with nothing between them that could reassign it. Leave everything else unverified.

It fails safe: setup still stops without allow_unverified=true and names the command it could not verify.

Part of #3042.

Review-Deferral: d528776e8b2b7451 severity=nit category=security
Review-Deferral: 6c8ff0d3c95257e0 severity=nit category=security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    P3

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions