Skip to content

ci: harden GitHub Actions workflows#350

Merged
jeremy merged 10 commits intomainfrom
flavorjones/harden-github-actions
Mar 20, 2026
Merged

ci: harden GitHub Actions workflows#350
jeremy merged 10 commits intomainfrom
flavorjones/harden-github-actions

Conversation

@flavorjones
Copy link
Member

@flavorjones flavorjones commented Mar 19, 2026

Summary

  • Pin all actions to SHA hashes with version comments via pinact
  • Fix zizmor findings by severity: excessive-permissions, secrets-outside-env, artipacked, dependabot-cooldown, cache-poisoning, dangerous-triggers
  • Move workflow-level permissions to per-job least-privilege grants with permissions: {} at workflow level
  • Add zizmor + actionlint CI job to test workflow
  • Add 10-day cooldown to all dependabot ecosystem entries

Test plan

  • CI passes on this branch
  • Verify zizmor reports clean: zizmor .

Summary by cubic

Hardened GitHub Actions by pinning actions to SHAs, enforcing deny-all with per-job least-privilege, and adding workflow linting. Also fixed shell quoting to eliminate SC2086 issues and corrected version comments on pinned actions.

  • Refactors

    • Set permissions: {} at workflow level and granted per-job minimal permissions (e.g., labeler, dependabot-auto-merge, security).
    • Added persist-credentials: false to all actions/checkout steps.
    • Documented safe pull_request_target and cache exceptions with zizmor suppressions; no PR code is checked out or executed in those jobs.
    • Added a CI job to run actionlint and zizmor on workflows.
    • Tightened Dependabot auto-merge to verify github.event.pull_request.user.login == 'dependabot[bot]'.
    • Quoted shell variable expansions to satisfy ShellCheck SC2086 and avoid word-splitting.
  • Dependencies

    • Pinned all actions to commit SHAs with version comments (e.g., actions/checkout v6.0.2, github/codeql-action v4.32.6, golangci/golangci-lint-action v9.2.0, dependabot/fetch-metadata v2.5.0, actions/create-github-app-token v3.0.0).
    • Increased Dependabot cooldowns to 10 days across ecosystems to avoid premature bumps.

Written for commit 69207e2. Summary will update on new commits.

flavorjones and others added 6 commits March 19, 2026 15:39
- Fix bot-conditions in dependabot-auto-merge.yml: use verified
  github.event.pull_request.user.login instead of spoofable github.actor
- Suppress dangerous-triggers in ai-labeler.yml, labeler.yml, and
  sensitive-change-gate.yml: pull_request_target is required for write
  access to PRs from forks; none of these workflows check out or
  execute PR code
- Suppress cache-poisoning in release.yml: GitHub Actions caches are
  branch-isolated so fork PRs cannot write to the cache used by
  tag-push workflows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e-env

- security.yml: set permissions: {} at workflow level and scope per job
- test.yml: suppress secrets-outside-env for skill-eval job (fork PRs
  don't receive secrets so untrusted code can't access the key;
  environment protection would block PR-triggered runs)
Increase default-days to 10 for all ecosystem entries to give a 10-day
waiting period after version publication before dependabot proposes it.
Add lint-actions job near the existing lint job in test.yml, running
actionlint and zizmor to keep GitHub Actions workflows audited in CI.
Copilot AI review requested due to automatic review settings March 19, 2026 20:22
@github-actions github-actions bot added the ci CI/CD workflows label Mar 19, 2026
@github-actions
Copy link

github-actions bot commented Mar 19, 2026

Sensitive Change Detection (shadow mode)

This PR modifies control-plane files:

  • .github/workflows/ai-labeler.yml
  • .github/workflows/dependabot-auto-merge.yml
  • .github/workflows/direct-push-alert.yml
  • .github/workflows/labeler.yml
  • .github/workflows/release.yml
  • .github/workflows/scorecard.yml
  • .github/workflows/security.yml
  • .github/workflows/sensitive-change-gate.yml
  • .github/workflows/test.yml

Shadow mode — this check is informational only. When activated, changes to these paths will require approval from a maintainer.

@github-actions github-actions bot added the enhancement New feature or request label Mar 19, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

This PR hardens the repository’s GitHub Actions CI/CD surface by pinning action references, tightening checkout credentials, adding workflow auditing, and reducing default token permissions (partially) to address zizmor findings.

Changes:

  • Pin more GitHub Actions uses to SHAs (with version comments) and set persist-credentials: false on checkouts.
  • Add CI auditing in test.yml via actionlint + zizmor.
  • Shift security.yml to workflow-level permissions: {} with explicit per-job permissions; update Dependabot cooldown and auto-merge gating.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.github/workflows/test.yml Pins actions, disables persisted checkout credentials across jobs, adds lint-actions job to run actionlint and zizmor.
.github/workflows/sensitive-change-gate.yml Documents/acknowledges pull_request_target risk with a zizmor ignore rationale.
.github/workflows/security.yml Sets workflow permissions to {} and grants least-privilege per job; pins actions and disables persisted checkout credentials.
.github/workflows/scorecard.yml Pins checkout and SARIF upload action; keeps Scorecard job permissions configuration.
.github/workflows/release.yml Pins actions, disables persisted checkout credentials, and adds zizmor ignore annotations for cache-poisoning findings.
.github/workflows/labeler.yml Adds zizmor ignore rationale for pull_request_target usage.
.github/workflows/dependabot-auto-merge.yml Tightens gating condition to ensure the PR author is Dependabot; pins metadata action.
.github/workflows/ai-labeler.yml Adds zizmor ignore rationale for pull_request_target usage.
.github/dependabot.yml Increases default Dependabot cooldown to 10 days for configured ecosystems.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replace overly broad workflow-level permissions blocks with `permissions: {}`
and move permissions to per-job scope, following least-privilege principle.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

.github/workflows/release.yml:311

  • The actions/create-github-app-token step in sync-skills is pinned to the same SHA as the earlier sdk-token step (commented as v3.0.0), but here the version comment still says # v2. This is misleading for audits/updates; please align the version comment with the actual release for that SHA (or update the SHA/comment pair consistently).
          persist-credentials: false

      - name: Generate token for skills repo
        id: skills-token
        uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

flavorjones and others added 2 commits March 19, 2026 17:34
…d local workflow lint

- Dependabot auto-merge: require both github.actor and user.login checks
  to prevent human-triggered events from re-entering the approve/merge path
- test.yml: deny-all at workflow level, explicit contents:read per job
  (consistent with the pattern established in all other workflow files)
- Makefile: add lint-actions target (actionlint + zizmor) wired into check,
  fail hard when tools are missing with cross-platform install hints
- make tools: install actionlint via go install, zizmor via brew/pacman
- bin/setup: full tool provisioning including workflow linters
Copilot AI review requested due to automatic review settings March 20, 2026 09:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
if: github.event.pull_request.user.login == 'dependabot[bot]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremy jeremy merged commit 0bb0bfb into main Mar 20, 2026
31 checks passed
@jeremy jeremy deleted the flavorjones/harden-github-actions branch March 20, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD workflows enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants