agentleFS
kaandgnshkaandgnsh/Claude-Blue/skills/devsecops/github-actions-hardening/SKILL.md

github-actions-hardening

Skill0 starsChanged 12 days agoMITView on GitHub

Audit and harden GitHub Actions workflows — pwn-request patterns (pull_request_target/workflow_run with untrusted checkout), script injection from github.event fields, unpinned third-party actions, GITHUB_TOKEN permissions, OIDC to cloud, self-hosted runner risk — with a bundled tested auditor plus zizmor/actionlint. Use when reviewing CI workflows, responding to a compromised action, or setting org-wide Actions policy.

  • Reads credentials

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never use repo:my-org/* or wildcard sub for deploy roles.

    line 44
  2. Very specific:

    Search all repos for the action and affected SHAs (gh search code "uses: org/action" --owner my-org or org-wide code search), review …

    line 48

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GitHub Actions Hardening

Audit

python3 scripts/gha_audit.py .github/workflows/          # bundled heuristic auditor, JSON output, exit 1 on high/critical
python3 scripts/gha_audit.py wf.yml --fail-on medium
zizmor .github/workflows/                                 # dedicated Actions security linter (more complete)
actionlint                                                # syntax + shellcheck of run blocks

The bundled auditor is line-based (no YAML parser): treat it as a fast first pass and confirm with zizmor.

Key risks and fixes

RiskFix
pull_request_target / workflow_run + checkout of PR head → untrusted code with secrets and write tokenUse pull_request for untrusted code; if pull_request_target is needed, never check out/execute PR code; split into unprivileged build + privileged comment job with artifacts treated as untrusted
Script injection: run: echo "${{ github.event.pull_request.title }}"Pass via env: and reference "$TITLE"; never interpolate event fields into run
Unpinned actions (@v4, @main) — tag hijacks (e.g. tj-actions/changed-files, March 2025)Pin to full commit SHA with a version comment; update via Dependabot/Renovate; restrict allowed actions at org level
Over-privileged GITHUB_TOKENOrg default to read-only; per-workflow permissions: least privilege
Long-lived cloud keys in secretsOIDC federation (id-token: write) with tight trust conditions on sub (repo, branch/environment)
Self-hosted runners on public reposDon't; use ephemeral, isolated runners (ARC, just-in-time) with no persistent credentials
Secrets exposure in logs/artifactsMask, avoid set -x, scan artifacts; environments with required reviewers for deploy secrets
Cache poisoningDon't share caches between untrusted PR and privileged workflows

AWS OIDC trust policy condition example

"Condition": {
  "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
  "StringLike": { "token.actions.githubusercontent.com:sub": "repo:my-org/my-repo:environment:production" }
}

Never use repo:my-org/* or wildcard sub for deploy roles.

Incident: compromised third-party action

Search all repos for the action and affected SHAs (gh search code "uses: org/action" --owner my-org or org-wide code search), review workflow run logs in the window for leaked secrets, rotate every secret available to those workflows, pin to a known-good SHA or remove.

Related skills

pipeline-threat-model, source-control-hardening, secret-leak-response, slsa-provenance

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.