SAASMENT

Security skill · Find and fix

CI/CD and GitHub Actions security review.

Review CI/CD pipelines, with a focus on GitHub Actions, for exposed secrets and excessive permissions, covering GITHUB_TOKEN scope, secret handling, untrusted triggers such as pull_request_target, script injection from event data, unpinned third-party actions, self-hosted runners, and cloud credentials, then fix and verify with test workflows. Use when auditing workflow files, a deployment pipeline, or a pull request that changes CI configuration.

Download .zipInstall via MCPFind and fixMIT
  • Misconfiguration

Facts

Category
Find and fix
License
MIT
Tags
  • Misconfiguration
Version
1.0.0
Last updated
2026-12-02
Folder
cicd-github-actions-security-review/
MCP resource
skill://cicd-github-actions-security-review/SKILL.md
Files
  • SKILL.md
  • LICENSE
  • references/actions-checks.md
Standards

Original Saasment content. Saasment is in early access; this skill does not require joining it.

Install via MCP or as files

Connect your client to https://www.saasment.com/api/mcp (see client setup) and call get_skill:

{
  "name": "get_skill",
  "arguments": {
    "slug": "cicd-github-actions-security-review"
  }
}

Or download the .zip and unpack it into your agent's skills directory:

Terminal, from your project root (user-level: ~/.cursor/skills)

mkdir -p .cursor/skills
curl -fsSL https://www.saasment.com/ai-security/skills/cicd-github-actions-security-review/download.zip -o /tmp/cicd-github-actions-security-review.zip
unzip -o /tmp/cicd-github-actions-security-review.zip -d .cursor/skills
# result: .cursor/skills/cicd-github-actions-security-review/SKILL.md

Review SKILL.md before enabling a skill. Skills are instructions your agent will follow.

SKILL.md

---
name: cicd-github-actions-security-review
description: Review CI/CD pipelines, with a focus on GitHub Actions, for exposed secrets and excessive permissions, covering GITHUB_TOKEN scope, secret handling, untrusted triggers such as pull_request_target, script injection from event data, unpinned third-party actions, self-hosted runners, and cloud credentials, then fix and verify with test workflows. Use when auditing workflow files, a deployment pipeline, or a pull request that changes CI configuration.
license: MIT
metadata:
  author: Saasment
  version: "1.0.0"
  category: both
  tags: "misconfiguration"
---

# CI/CD and GitHub Actions security review: secrets and permissions (find and fix)

License: MIT. Copyright (c) 2026 Saasment. Source: https://www.saasment.com/ai-security/skills/cicd-github-actions-security-review

A CI pipeline holds credentials, runs code, and can publish software, so it is a high-value target. Most pipeline incidents trace back to a few misconfigurations: tokens with more permission than a job needs, secrets exposed to code from forks or to untrusted input, workflow steps that paste attacker-controlled text into a shell, third-party actions that can change under you, and long-lived cloud keys stored as secrets. This skill reviews GitHub Actions in detail; the same questions apply to other CI systems.

## When to use

- You audit `.github/workflows/*.yml`, reusable workflows, composite actions, or deployment pipelines.
- A pull request adds or changes a workflow, a trigger, a secret, or a runner.
- You respond to a leaked token or a suspicious workflow run.

## Safe by default

- Review only repositories and organizations you own or are authorized to assess.
- Read workflow files and settings first. Do not trigger runs on production environments, re-run workflows with new secrets, or push test changes to protected branches as part of a review. Use a scratch repository or fork you own for experiments.
- Never print secrets, even masked ones, to prove a finding. Show that a secret is reachable by naming the step and condition, and test with a dummy secret in a scratch repository.
- If a secret was exposed in logs, history, or an artifact, treat it as compromised: revoke and rotate it (see `secrets-in-repo-scan-and-rotation`).
- Pipeline changes can block deployments. Make them in small pull requests and keep a way to roll back.

## Procedure

1. **Inventory.** List workflows, triggers, reusable workflows and actions they call, environments, runners (hosted or self-hosted), secrets and variables (repository, environment, organization), and which workflows deploy. Commands and a template are in `references/actions-checks.md`.
2. **Review token permissions.** Each workflow or job sets `permissions:` explicitly with the minimum scopes (start from `contents: read`); repository and organization defaults for `GITHUB_TOKEN` are read-only; write scopes (`contents`, `packages`, `pull-requests`, `id-token`) appear only in jobs that need them.
3. **Review triggers.** `pull_request_target` and `workflow_run` run with repository secrets and write tokens; they must not check out or execute code from the pull request head. `issue_comment` and `issues` workflows treat all text as untrusted. Workflows triggered by forks do not receive secrets. Manual and scheduled triggers are limited to protected branches.
4. **Review script injection.** Expressions such as `${{ github.event.pull_request.title }}`, issue and comment bodies, branch names, commit messages, and `github.head_ref` inserted directly into `run:` scripts or `github-script` code allow command injection. Pass untrusted values through `env:` and reference them as shell variables, or avoid the shell.
5. **Review third-party actions.** Actions from outside your organization are pinned to a full commit SHA, not a tag or branch; reusable workflows are pinned the same way; each action is read or at least reviewed for what it receives (secrets, tokens, write access); an allowlist of permitted actions is configured at the organization level; update tooling is configured to propose pinned updates.
6. **Review secret handling.** Secrets are scoped to the environment that needs them; deployment secrets live in protected environments with required reviewers and branch restrictions; secrets are not echoed, written to files that become artifacts, or passed on command lines; caches and artifacts do not contain credentials; debug logging is not enabled in shared workflows.
7. **Review cloud credentials.** Prefer OpenID Connect federation to cloud roles over stored long-lived keys, with trust conditions limited to the repository, branch or environment; cloud roles used by CI have narrow permissions (see `cloud-iam-storage-exposure-review`).
8. **Review runners.** Self-hosted runners are not used for public repositories or for untrusted pull requests; they are ephemeral where possible, isolated from internal networks and from each other, and kept patched; hosted runners are used for untrusted code.
9. **Review release integrity.** Builds are reproducible enough to trust, publishing steps need protected environments, packages and images are signed or have provenance attestations where supported, and branch protection requires review for workflow changes (use code owners on `.github/`).
10. **Fix** in small pull requests: add `permissions`, pin actions, move expressions into `env`, restrict triggers, switch to OIDC, scope secrets to environments, and rotate anything exposed. Add a workflow linter to CI.

## Verification

- Confirm token scope: add a temporary step in a scratch repository that calls an API operation that needs write access and confirm it fails with the reduced `permissions`; confirm the legitimate steps still pass.
- Confirm script-injection fixes in a scratch repository: open a pull request whose title contains harmless shell metacharacters such as `"; echo marker; "` and confirm the workflow log shows the text as a literal string and no `marker` command output.
- Confirm fork behavior: open a pull request from a fork you control and confirm secrets are empty and write tokens are not granted in `pull_request` workflows.
- Confirm pinning: run a workflow linter or search to confirm every third-party `uses:` is a full-length commit SHA with a comment naming the version.
- Confirm OIDC trust: attempt to assume the cloud role from a different branch or repository in a test setup and confirm denial.
- Confirm protected environment gates: trigger a deployment job in a scratch repository and confirm it waits for the required reviewer.

## Reporting

Table: finding id, workflow file and line, issue, who can exploit it (fork, commenter, maintainer), what is exposed, fix, verification. List secrets that need rotation and repository or organization settings that need an administrator.

## References

- GitHub: security hardening for GitHub Actions: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
- GitHub: automatic token authentication (`GITHUB_TOKEN`): https://docs.github.com/en/actions/security-guides/automatic-token-authentication
- GitHub: using secrets in GitHub Actions: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
- GitHub: OpenID Connect in cloud providers: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
- GitHub Security Lab: preventing pwn requests: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
- OWASP CI/CD Security Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/CI_CD_Security_Cheat_Sheet.html
- Companion skills: `secrets-in-repo-scan-and-rotation`, `cloud-iam-storage-exposure-review`, `pull-request-security-review`, `docker-image-security-review`.

Helper files

LICENSE
MIT License

Copyright (c) 2026 Saasment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
references/actions-checks.md
# GitHub Actions checks

License: MIT. Copyright (c) 2026 Saasment.

Workflow syntax and settings change over time; confirm against GitHub's current documentation.

## Search commands (read-only)

```bash
# Workflows and their triggers
ls .github/workflows
rg -n '^on:|^\s+(pull_request_target|workflow_run|issue_comment|issues|workflow_dispatch|schedule)' .github/workflows

# Permissions: workflows with no explicit block
rg -L '^permissions:' .github/workflows
rg -n 'permissions:|write-all|contents: write|id-token: write|pull-requests: write' .github/workflows

# Untrusted expressions used inside scripts
rg -n '\$\{\{\s*github\.(event\.(issue|pull_request|comment|review|head_commit|commits)|head_ref)' .github/workflows

# Third-party actions not pinned to a full commit SHA
rg -n 'uses:\s*[^./][^@]+@' .github/workflows | rg -v '@[0-9a-f]{40}'

# Secrets usage and echoing
rg -n 'secrets\.' .github/workflows
rg -n 'echo .*secrets\.|ACTIONS_STEP_DEBUG|ACTIONS_RUNNER_DEBUG' .github/workflows

# Self-hosted runners
rg -n 'runs-on:.*self-hosted' .github/workflows

# Workflow linter (static analysis for workflow files)
actionlint
```

## Read-only settings checks (GitHub CLI, with a token that can read settings)

```bash
# Default workflow permissions and allowed actions for a repository
gh api repos/<owner>/<repo>/actions/permissions
gh api repos/<owner>/<repo>/actions/permissions/workflow

# Secrets and variables (names only; values are never returned)
gh secret list --repo <owner>/<repo>
gh variable list --repo <owner>/<repo>

# Environments and protection rules
gh api repos/<owner>/<repo>/environments
```

## Safer workflow patterns

```yaml
name: ci
on:
  pull_request:           # forks get no secrets and a read-only token
    branches: [main]

permissions:
  contents: read          # least privilege by default

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full-commit-sha>   # v-tag noted in a comment
        with:
          persist-credentials: false
      - name: Show title safely
        env:
          PR_TITLE: ${{ github.event.pull_request.title }}   # untrusted text goes in env
        run: printf '%s\n' "$PR_TITLE"
      - run: npm ci --ignore-scripts && npm test

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production        # protected environment: reviewers and branch rules
    permissions:
      contents: read
      id-token: write              # only this job may request an OIDC token
    steps:
      - uses: actions/checkout@<full-commit-sha>
      - uses: <cloud-login-action>@<full-commit-sha>
        with:
          role-to-assume: <role-arn-or-equivalent>   # trust limited to this repo and environment
```

## Patterns to flag

| Pattern | Risk | Fix |
| --- | --- | --- |
| No `permissions:` and repository default is read-write | Token can modify code, packages, and issues | Explicit least-privilege `permissions` |
| `pull_request_target` plus checkout of the PR head | Untrusted code runs with secrets and a write token | Use `pull_request`, or split into an unprivileged build and a privileged follow-up that treats artifacts as untrusted |
| `${{ github.event.* }}` inside `run:` | Command injection from titles, bodies, branch names | Pass through `env:` and quote the variable |
| `uses: owner/action@v3` or `@main` | The tag or branch can be moved | Pin to a full commit SHA |
| Cloud keys in secrets | Long-lived and reusable if leaked | OIDC federation with narrow trust conditions |
| Secrets at repository level used only for deploys | Every workflow and branch can read them | Environment secrets with required reviewers |
| Self-hosted runner on a public repository | Anyone's pull request code runs on your machine | Hosted runners for untrusted code, ephemeral runners otherwise |
| `actions/checkout` with default credentials persisted | Later steps can push with the token | `persist-credentials: false` |
| Artifacts or caches containing `.env` or config | Credentials downloadable by others with read access | Exclude secrets, short retention |

## Response when a secret may have leaked

1. Revoke or rotate the secret at the provider first.
2. Search workflow logs, artifacts, and caches for use of the old value and delete exposed artifacts.
3. Review the cloud or service audit log for use of the credential since the exposure.
4. Fix the cause (permissions, trigger, injection) and re-run a scan on the repository history.

Related

Companion skills

Questions

How do I install the CI/CD and GitHub Actions security review skill?

Download https://www.saasment.com/ai-security/skills/cicd-github-actions-security-review/download.zip and unzip it into your agent's skills directory (for example .cursor/skills, .claude/skills, .agents/skills, or .github/skills) so that cicd-github-actions-security-review/SKILL.md exists. Or connect to https://www.saasment.com/api/mcp and call the get_skill tool with the slug cicd-github-actions-security-review.

What license is the CI/CD and GitHub Actions security review skill under?

It is original Saasment content under the MIT license, stated in the SKILL.md frontmatter and in the LICENSE file in the skill folder.

Is it safe to run this skill?

A skill is a set of instructions your agent follows, so read SKILL.md first. It tells the agent to test only systems you own or are authorized to test, to use test environments and synthetic data, and to avoid destructive probes. Downloading it does not run any code on your machine.

← All security skills

Try the platform.

Open the demo workspace with mock data. No login. Register from the banner when you want early access. No security team. No call.

Try the platform