Schedule icon
Download icon
Script icon
Loop icon
WorkingDirectory icon
Clone icon
SlackIncomingWebhook icon
Set icon
If icon
Pause icon
Request icon
PushExecutionFiles icon
Create icon

GitHub Actions Hardening Sweep with zizmor, SHA Pinning and Approval

Audit every GitHub Actions workflow in an org with zizmor, track risk week over week, and open SHA-pinning PRs after approval.

Categories
Infrastructure

In March 2025, attackers moved the version tags of tj-actions/changed-files to malicious code, and more than 23,000 repositories leaked CI secrets in their logs. Any workflow that uses an action by tag (@v4) runs whatever that tag points to today. The standard fix is pinning every action to a full commit SHA, but doing that and keeping watch across dozens of repositories by hand doesn't happen. This blueprint sweeps a whole organization every week. It's for security and platform teams that own CI across many repositories.

How it works

  1. list_repos (io.kestra.plugin.core.http.Download) lists the owner's repositories that aren't archived or forks, and select_repos (io.kestra.plugin.scripts.python.Script) applies the optional repository list and max_repos. Names that are missing, archived or forks are reported as not scanned.
  2. audit (io.kestra.plugin.core.flow.Loop, four repositories at a time, transmitFailed: false so one broken repository doesn't stop the sweep) clones each repository (io.kestra.plugin.git.Clone). scan_and_pin then:
    • runs zizmor offline on every workflow and composite action. zizmor finds unpinned actions, dangerous triggers such as pull_request_target, template injection, excessive permissions, credential persistence and more;
    • resolves every action referenced by a tag or branch to its commit SHA through the GitHub API, and rewrites it as owner/repo@<sha> # <tag>. Local actions, docker:// images and skip_action_owners are left alone.
  3. report writes report.md: a per-repository table, the findings at or above min_severity with links to zizmor's documentation, the pins, and the repositories not scanned. Each count shows its change since the previous run, read from the KV store. post_report (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts the summary, and save_baseline (io.kestra.plugin.core.kv.Set) stores this run's counts.
  4. When this isn't a dry run and something can be pinned, ask_reviewer posts a link and approval (io.kestra.plugin.core.flow.Pause) waits for a decision: open pinning PRs, or report only. Without a decision within three days, the execution is cancelled.
  5. On approval, per_repository (Loop, three at a time) skips repositories that already have an open security/pin-actions PR. For the rest, push_branch (io.kestra.plugin.git.PushExecutionFiles, delete: false) commits only the edited workflow files, open_pr (io.kestra.plugin.github.pulls.Create) opens the PR, and announce_prs posts the links.
  6. alert_failure posts any failure to Slack.

The pinning PRs change no behaviour: each SHA is the commit the tag points to at the time of the sweep, and the tag stays as a comment so Dependabot and Renovate keep proposing updates. Other findings are listed for a person to fix, because zizmor's automatic fixes for them change behaviour.

Prerequisites

  • Docker on the worker for the Python script tasks. zizmor is installed from PyPI at run time.
  • Secrets:
    • GITHUB_TOKEN: a token that can read the owner's repositories. For the pinning PRs, it also needs Contents: read and write and Pull requests: read and write on those repositories. It's also used as the HTTPS username for cloning, which GitHub accepts.
    • SLACK_WEBHOOK_URL: Slack incoming webhook for the report, the review request and failure alerts.

Inputs

  • owner (STRING, default your-org): the organization or user to sweep.
  • repositories (STRING, default empty): comma-separated repository names to limit the sweep to. Empty means every repository that isn't archived or a fork.
  • max_repos (INT, default 30): the most repositories scanned in one run.
  • skip_action_owners (STRING, default empty): action owners to leave on tags, for example your own organization.
  • min_severity (SELECT low, medium or high, default medium): the lowest severity listed in the report. The counts always include everything.
  • dry_run (BOOL, default true): scan, resolve SHAs and report, but no approval request and no PRs. The report and the KV baseline are still produced.

Quick start

  1. Add the two secrets and save the flow.
  2. Run it manually with owner set and dry_run left on. Read report.md in the report outputs.
  3. Run it again with dry_run set to false, approve, and review the pinning PRs.
  4. Enable the weekly trigger to sweep every Monday. Set its inputs if your defaults differ.

Outputs

  • {{ outputs.report }} / {{ outputs.report.outputFiles['report.md'] }}: the full report.
  • {{ outputs.high_findings }} / {{ outputs.report.vars.totals }}: findings per severity across all repositories.
  • {{ outputs.actions_to_pin }} / {{ outputs.report.vars.pins_total }}: action references that can be pinned.
  • {{ outputs.report.vars.not_scanned }}: repositories that were missing, archived, forks or failed to scan.
  • {{ loopOutputs(outputs.per_repository.outputs, 'pull_request') }}: the pinning PRs.
  • KV key actions-hardening-<owner>: this run's counts per repository, the baseline for the next run.

Common pitfalls

  • The repository list comes from GitHub search, which returns at most 100 repositories per owner. Use repositories to pick specific ones in larger organizations.
  • A tag that GitHub can't resolve, such as a deleted tag or a private action the token can't read, is listed in the report to pin by hand.
  • While a security/pin-actions PR is open in a repository, that repository is skipped. Merge or close it, and the next sweep proposes the rest.
  • zizmor runs offline, so audits that need the GitHub API, such as known-vulnerable actions, are not included.

How to extend

  • Pass --gh-token to zizmor for its online audits, such as known-vulnerable or impostor commits.
  • Open issues instead of PRs for findings that need a person, with io.kestra.plugin.github.issues.Create.
  • Fail a pipeline when high findings increase, by comparing outputs.report.vars.totals.high with the baseline.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.