Ci cd security

From superagent-ai/skills · View interactive version

Ci cd security is an AI agent skill from the GitHub repository superagent-ai/skills. Scan GitHub Actions workflow files for security vulnerabilities by reading the YAML and reporting findings directly — no external tools, no installation, no shell execution. Use this skill whenever the user shares a `.github/workflows/` file, pastes workflow YAML, asks for a CI/CD security review, m

How to use this skill

Skill file

CI/CD Security Scanner

This skill turns the model into a workflow-YAML scanner. Read the file, walk the detection rules, report findings with severity and a concrete rewrite. No tools to install, no commands to run — the analysis is the model reading the YAML.

The rules encode the current consensus from Astral, OpenSSF, GitHub Security Lab, Chainguard, and the zizmor audit set. The goal is to flag the same patterns those tools would flag, without needing to run them.

Mental model

Every workflow sits on a 2x2: privileged vs unprivileged crossed with trusted vs untrusted code. Compromise happens at exactly one cell: privileged workflow running untrusted code. The rules below are ways to detect when a workflow ends up in that cell.

When unsure whether a value is trusted, treat it as untrusted. The cost of a false positive is a code review comment; the cost of a false negative is a supply chain compromise.

Scan procedure

For each workflow file the user provides, walk these passes in order. Each pass corresponds to a class of attack.

Pass 1: dangerous triggers

Look at the on: block. Flag immediately:

For each finding: name the trigger, explain why it's dangerous in this specific workflow's context, and propose the rewrite (usually pull_request, sometimes a split into two workflows, sometimes "this needs a GitHub App not Actions").

Pass 2: permissions

Look for permissions: blocks at workflow and job level.

Pass 3: action pinning

Look at every uses: line.

The rewrite for tag/branch pinning is always: replace with the full 40-character commit SHA of the version they intended, plus a # vX.Y.Z comment.

Pass 4: shell injection (template injection)

For every run: block, scan for ${{ ... }} substitutions.

Constant or non-attacker-controlled values are fine (e.g. ${{ matrix.os }}, ${{ secrets.MY_TOKEN }} though even that's risky in some contexts). The dangerous fields are:

Detection rule: if a run: block contains ${{ github.event.* }} or ${{ github.head_ref }} directly in the script body, that's P0 template injection. The fix is always:

# vulnerable
- run: echo "Branch is ${{ github.head_ref }}"

# safe
- env:
    BRANCH: ${{ github.head_ref }}
  run: echo "Branch is $BRANCH"

Also flag (P1):

Pass 5: untrusted checkout

For every actions/checkout step:

Pass 6: caching in privileged contexts

For every step using cache: input (most commonly on actions/setup-node, setup-python, setup-go, setup-java, or direct actions/cache):

The rewrite for release workflows: remove cache: entirely, add a comment explaining why (e.g. # Do not cache: see https://github.com/actions/setup-node/issues/1445).

Pass 7: artifact-borne injection

If the workflow downloads artifacts from another workflow (actions/download-artifact, dawidd6/action-download-artifact, etc.):

Pass 8: release-specific hardening

If the workflow looks like a release/publish workflow (publishes to npm, PyPI, crates.io, Docker registries; creates GitHub releases; pushes tags):

Pass 9: self-hosted runners

If the workflow uses runs-on: with anything other than GitHub-hosted runners (ubuntu-*, windows-*, macos-*):

Finding format

Report each finding in this structure. Group by severity, P0 first.

[P0] template-injection in .github/workflows/ci.yml:23
  Run block interpolates github.event.pull_request.title directly into shell.
  An attacker controls the PR title and can execute arbitrary code in the
  workflow context, which has access to GITHUB_TOKEN.

  Vulnerable:
    - run: echo "Title: ${{ github.event.pull_request.title }}"

  Fix:
    - env:
        TITLE: ${{ github.event.pull_request.title }}
      run: echo "Title: $TITLE"

If the user pastes raw YAML without a filename, refer to it as "the workflow" and use line numbers within the snippet.

Severity scale

When the workflow looks fine

After walking all nine passes, if nothing fires:

  1. Say so explicitly. "No findings against the standard rule set."
  2. Note what wasn't checked: org-level settings (default token permissions, ruleset enforcement, 2FA), repo-level settings (branch protection, tag protection, immutable releases), action source code (whether the pinned actions themselves install mutable binaries at runtime), and runtime behavior of dependencies.
  3. Recommend the user check the items in references/checklist.md under "Per repository" and "Per organization" — those need GitHub settings access, not workflow YAML.

A clean workflow scan does not mean a clean security posture.

Reference files

What this skill won't do

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.