Skip to content

fix: recognize github.workflow_sha / github.sha as trusted refs (FG-001/016)#26

Merged
north-echo merged 1 commit into
mainfrom
fix/trusted-ref-workflow-sha
Jul 18, 2026
Merged

fix: recognize github.workflow_sha / github.sha as trusted refs (FG-001/016)#26
north-echo merged 1 commit into
mainfrom
fix/trusted-ref-workflow-sha

Conversation

@north-echo

Copy link
Copy Markdown
Owner

Summary

Surfaced by triaging an AI-bot hunt hit: leanprover-community/mathlib4's PR_summary.yml was false-flagged FG-001 + FG-016 critical, but it's a deliberately hardened pull_request_target workflow — fork code isolated to pr-branch/, local actions and scripts loaded from a separate checkout at github.workflow_sha, fork files processed only as data. The scanner just didn't know github.workflow_sha is a trusted ref.

  • isTrustedRef now accepts github.workflow_sha and github.sha (both check out trusted base/workflow code on pull_request_target, unlike ...head.sha). Safe substring: github.sha doesn't appear inside ...head.sha.
  • FG-016 gets localActionUnderTrustedCheckout() — a uses: ./<dir>/... action whose <dir> was populated by a trusted-ref checkout isn't attacker-controlled. (The earlier trusted-ref fix only credited a trusted checkout at root; this handles one into a subdir, which is the mathlib4 shape.)

Verified

leanprover-community/mathlib4 PR_summary.yml: FG-001 critical + FG-016 critical → zero critical/high. Tests added (isTrustedRef unit test incl. head.sha regression guard; FG-016 workflow_sha-dir fixture). Full suite, gofmt, vet, self-scan clean.

🤖 Generated with Claude Code

…01/016)

isTrustedRef knew main/master/base_ref/pull_request.base.* but not
github.workflow_sha or github.sha, both of which check out trusted
base/workflow code on pull_request_target (unlike ...head.sha, the fork).
Workflows that isolate fork code to a subdir and load actions/scripts
from a separate checkout at github.workflow_sha (e.g. mathlib4's
PR_summary.yml) were false-flagged.

- Add github.workflow_sha / github.sha to isTrustedRef (safe: "github.sha"
  is not a substring of "...head.sha").
- FG-016: new localActionUnderTrustedCheckout() — a `uses: ./<dir>/...`
  action whose <dir> was populated by a trusted-ref checkout is not
  attacker-controlled (the prior fix only credited a trusted checkout at
  root; this handles a trusted checkout into a subdir).

Verified: leanprover-community/mathlib4 PR_summary.yml goes from
FG-001 critical + FG-016 critical to zero critical/high.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@north-echo
north-echo merged commit c2820a7 into main Jul 18, 2026
1 check passed
@north-echo
north-echo deleted the fix/trusted-ref-workflow-sha branch July 18, 2026 01:26
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.

1 participant