Skip to content

detect caller/callee permission mismatch in reusable workflow calls#670

Open
SeriousBug wants to merge 3 commits into
rhysd:mainfrom
SeriousBug:caller-callee-permissions
Open

detect caller/callee permission mismatch in reusable workflow calls#670
SeriousBug wants to merge 3 commits into
rhysd:mainfrom
SeriousBug:caller-callee-permissions

Conversation

@SeriousBug

Copy link
Copy Markdown

GitHub validates permissions: at workflow load time. When a job in a called reusable workflow declares a scope the calling job does not grant, the run aborts with startup_failure before any job can run.

This PR adds a check under the existing workflow-call rule that compares each callee job's effective permissions against the caller's effective grant and reports each missing scope.

When the caller has no permissions: block at the workflow level and none on the calling job, the check assumes GitHub's restricted default token (contents: read + packages: read). This mirrors the repo-level "Workflow permissions" setting (Settings → Actions → General), which actionlint can't read from the workflow file. So unfortunately we need to introduce a config for this, assume-default-permissions:

  • restricted (default) — assume the restricted default
  • permissive — assume read+write on everything, which effectively skips the check for callers with no permissions block

Closes #552

GitHub validates `permissions:` at workflow load time. When a job in a called
reusable workflow declares a scope the calling job does not grant, the run
aborts with startup_failure before any job (including if: failure() handlers)
can run. Add a check under the existing workflow-call rule that compares each
callee job's effective permissions against the caller's effective grant and
reports each missing scope. The check ignores `if:` on callee jobs because
GitHub evaluates permissions regardless of the runtime gate.

When the caller declares no permissions: block at all, assume GitHub's
restricted default token (contents/packages read). This default can be
overridden via the new `assume-default-permissions` config knob, which mirrors
the repository-level Workflow permissions setting that actionlint cannot read
from the workflow file. Set to `permissive` to skip the comparison when the
caller is fully silent.
Drop the 'fully silent' jargon and spell out what it means: caller has no
permissions: block at the workflow level and none on the calling job.
- fix permissive mode silently skipping id-token (always requires opt-in)
- restore WriteWorkflowCallEvent signature; add WriteWorkflowCallEventFromWorkflow
- clamp callee values symmetrically so id-token: read collapses to none
- remove dead !callerSilent branch via callerLevel/silentDefaultLevel split
- drop unused scope param from permissionLevel
- replace sort.Strings with slices.Sort; use n.Kind == 0 for node absence
- update docs to call out id-token exception under permissive
- add tests for id-token, write-all callee, clamping, unknown scopes
@SeriousBug SeriousBug marked this pull request as ready for review May 25, 2026 06:47
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.

Actionlint should check permissions passed to reusable workflows (in the same repository)

1 participant