workflow-sentinel

Sentinel · security scanner

workflow-sentinel

Catch insecure GitHub Actions workflows before they're merged.

npm i -D workflow-sentinel

What it checks

  • dangerous-checkoutpull_request_target / workflow_run that checks out the PR head (ref: ${{ github.event.pull_request.head.sha }}, github.head_ref, refs/pull/…, gh pr checkout)
  • unpinned-actionuses: with a tag or branch instead of a 40-char commit SHA (steps, reusable workflows, composite actions)
  • broad-permissionspermissions: write-all at workflow or job level. Top-level write scopes shared by several jobs are reported as low
  • script-injection${{ github.event.issue.title }}, …pull_request.body, github.head_ref, comment bodies, commit messages and similar values pasted into run: or actions/github-script. ${{ inputs.* }} in composite actions is reported as medium
  • secrets-untrustedSecrets used in a job that runs checked-out PR code. Echoing ${{ secrets.* }} is reported as medium
  • self-hosted-prruns-on: self-hosted in a workflow triggered by pull requests or comments
  • missing-permissionsNo top-level permissions: and jobs without their own
  • persist-credentialsactions/checkout without persist-credentials: false

Quick usage

CLI

npx workflow-sentinel                      # scan the current repository
npx workflow-sentinel .github/workflows/release.yml --fail-on medium
npx workflow-sentinel --trusted-owner actions --trusted-owner github
GH_TOKEN=... npx workflow-sentinel --fix   # pin every action to its current commit SHA (# v4 comment for Dependabot)

API

import { scan, scanText, formatSarif } from 'workflow-sentinel';
const { findings } = scan({ cwd: '.', config: { trustedOwners: ['actions'] } });

Every option is documented in the workflow-sentinel docs.

CI / GitHub Action

name: Workflow security
on: [push, pull_request]
permissions:
  contents: read
  security-events: write
jobs:
  workflow-sentinel:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false }
      - uses: MrLouisWright/workflow-sentinel@v1
        with:
          fail-on: high
          sarif: workflow-sentinel.sarif
      - if: always()
        uses: github/codeql-action/upload-sarif@v3
        with: { sarif_file: workflow-sentinel.sarif }