GitHub Actions Workflow Checker
Operator: Abdulla Al Fahad. How tools are built and checked
A workflow file fails in two very different ways. Some mistakes stop it from running at all: a needs: that names a job that does not exist, an expression with an unclosed parenthesis, a runs-on label for an image GitHub has removed. Others let it run and quietly hand an attacker the repository: a pull request title pasted into a shell command, or a pull_request_target job that checks out the pull request's own code.
This checker reads the file through a guarded YAML parser and reports both kinds, each with the line it comes from and, where there is one, the fix. It covers structure, ${{ }} expressions, the needs graph, action pinning, script injection, risky triggers, permissions, deprecated commands and a few housekeeping suggestions. It works on the text alone: it does not call GitHub, resolve action versions or run anything.
Key features
- Schema checks: top-level keys, event names, job and step keys, job and step ids, runs-on, steps versus uses, cron syntax and workflow_dispatch input types
- Expression checks on every ${{ }} and on if: values: balanced quotes and brackets, known contexts and functions with the right number of arguments, and context use that cannot work (secrets in if:, needs of a job that is not listed, matrix without a matrix)
- needs: missing jobs, self-references and cycles, reported with the loop path
- Unpinned actions (branch, tag, short SHA or none), unpinned Docker images and older major versions of well-known actions
- Script injection from event data in run: and github-script, and pull_request_target or workflow_run checkouts of untrusted code
- Missing or over-broad permissions, retired runner images, deprecated and disabled workflow commands, missing timeouts and concurrency
What is checked and what needs GitHub itself
A workflow has on (the events that start it), optional workflow-level permissions, env and concurrency, and jobs. Each job needs runs-on and steps unless it calls a reusable workflow with uses. A step has either uses (an action, written owner/repo@ref, ./path or docker://image) or run (a shell script), never both. Expressions are written ${{ expression }}; an if: value is itself an expression, with or without the wrapper.
The checker knows the twelve contexts (github, env, vars, job, jobs, steps, runner, secrets, strategy, matrix, needs, inputs), the functions contains, startsWith, endsWith, format, join, toJSON, fromJSON and hashFiles, and the four status functions always, success, failure and cancelled. A single = or & in an expression is an error, and so is a double-quoted string, because expressions use single quotes.
Script injection happens because ${{ }} is replaced with its value before the shell sees the script. If the value comes from an issue title, a branch name or a commit message, whoever wrote it can close the quote and add commands. The list of event fields treated as controllable starts from the untrusted-input examples in GitHub's security-hardening guide and adds a few the guide does not spell out: titles, bodies and comments of issues, pull requests, reviews, review comments and discussions; github.head_ref and the pull request's head ref and label, which the author picks even from a fork; workflow_run head_branch, display_title and head commit text; the same fields on check_suite; commit messages and author and committer names; page names; and client_payload. Bracket forms such as github.event['issue']['title'] count the same as dotted ones, and a whole object such as github.event.issue or toJSON(github.event) is reported because it carries every one of those fields. All of these are errors. github.ref_name and workflow_dispatch inputs are notes: ref_name in a pull_request run is N/merge, which holds no attacker-chosen text, and in a push it names a branch that someone with write access created.
pull_request_target runs in the context of the base repository, with a token that can write and with access to secrets, even when the pull request comes from a fork. Checking out github.event.pull_request.head.sha there, and then building or testing that code, executes the fork's code with those privileges. The checker reports that pattern as an error, and a similar checkout under workflow_run as a warning.
How it works
YAML goes through the project's guarded parser, which has size, nesting and alias-expansion limits; a file whose aliases expand to more than a million values is refused. The parser does not keep positions, so a second pass reads indentation to map each key path to its line, and findings inside a block scalar are placed on the line that contains the expression.
Expressions are tokenised and checked without being evaluated: the context names, function names and argument counts come from lists, and references such as needs.build.result or steps.report.outputs are compared with what the job actually declares.
The needs graph is walked with an iterative depth-first search, so a long or circular chain is reported once as a loop (a > b > c > a) and never causes recursion. Work counters stop the scan of a pathological file instead of letting it run on.
Retired runner labels, outdated action majors and the list of controllable event fields are built into the page and reflect GitHub's documentation at the time of writing; they are not fetched.
When to run it
- A maintainer reviewing a contributor's workflow change pastes it and sees script-injection on a step that echoes github.event.workflow_run.display_title, a field a pull request author controls even though the workflow does not trigger on pull_request.
- A security engineer sweeping 40 repositories after an advisory pastes each workflow and filters for pull_request_target checkouts and unpinned third-party actions.
- A developer whose workflow suddenly shows no jobs at all pastes it and finds a cycle: lint, build and test each wait for the next.
Running a check
- Paste the workflow or open a .yml file; Load example fills in a deliberately flawed pull_request_target workflow.
- Press Check workflow. The totals at the top split the findings into errors, warnings and notes.
- In Findings, start with the errors. Each row gives a line number, a rule name and, where one exists, the replacement to write.
- Open Source to see the file with the offending lines shaded.
Example
The bundled 26-line pull_request_target workflow
on: pull_request_target
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: echo "Building ${{ github.event.pull_request.title }}"
notify:
needs: [build, publish]Selected findings (14 in all: 5 errors, 5 warnings, 4 notes)
error line 9 retired-runner ubuntu-20.04 was retired by GitHub in April 2025
error line 11 prt-checkout pull_request_target checks out the pull request's own code
error line 17 script-injection run: inserts github.event.pull_request.title into the script text
error line 22 needs-missing needs: "publish" is not a job in this workflow
error line 24 expr-syntax always( : A parenthesis is not closed.Limits
The page cannot resolve a tag to a commit, so it suggests pinning but never prints a SHA. Looking one up needs GitHub.
It does not know your repository's settings. Whether the default GITHUB_TOKEN permission is read-only or read and write is a repository or organisation setting, which is why the missing-permissions finding is phrased as a risk.
Reusable workflows and composite actions are checked only as far as their uses: line. What happens inside them needs their own files.
Expressions are checked for form, not for value. contains(github.ref, 'main') is accepted, and the page cannot tell whether it is the condition you meant.
A clean result means none of these rules fired. It is not a statement that the workflow is secure.
- When a finding says to pass a value through env:, write env: TITLE: ${{ github.event.pull_request.title }} on the step and use "$TITLE" in the script; the shell then treats it as data.
- To pin an action, look up the commit a tag points to on the action's releases page and keep the tag in a trailing comment, so tools that update pins can still read the version.
Common errors and how to fix them
- "YAML syntax error: ..."
- The message carries the line and column from the parser. Typical causes in workflows are a tab used for indentation, an unquoted value that contains ': ', and a missing space after a dash.
- "Its aliases expand to more than 1,000,000 values, so the file was not checked."
- Aliases that refer to other aliases many times can turn a small file into an enormous one. GitHub rejects such files too; rewrite the repeated part as a reusable workflow or a composite action.
- "The secrets context cannot be used in an if: condition."
- Copy the secret into an environment variable at the job level and test whether that variable is empty, or gate the step on a non-secret input.
Best practices
- Set permissions: contents: read at the top of every workflow and grant more only to the job that needs it.
- Prefer pull_request for code from forks, and use pull_request_target only for workflows that never run the pull request's code.
- Give long jobs a timeout-minutes of roughly twice their normal duration, so a hung step does not hold a runner for the 360-minute default.
The deprecated commands
::set-output and ::save-state were deprecated in October 2022 in favour of writing name=value lines to the files named by GITHUB_OUTPUT and GITHUB_STATE, and they print a warning when used. ::set-env and ::add-path were disabled in 2020 after a security issue, so a step that uses them silently does nothing; the replacements are the GITHUB_ENV and GITHUB_PATH files. Setting ACTIONS_ALLOW_UNSECURE_COMMANDS only re-enables the two disabled commands, and is flagged for that reason.
Schedules
Each schedule entry needs five cron fields in the ranges minute 0-59, hour 0-23, day 1-31, month 1-12 and weekday 0-6. GitHub runs scheduled workflows at most every five minutes, so */2 in the minute field is reported. A schedule that fires at minute 0 of every hour competes with everyone else's, so it gets a note suggesting an off-peak minute.
Frequently asked questions
Does it run the workflow or contact GitHub?
No. It parses the text and applies its rules. Whether an action exists, whether a SHA is current, and what the repository's settings are all need GitHub, so they are outside what it can say.
Why is actions/checkout@v4 flagged when it is the official action?
As a note, because a tag can be moved by the owner of the repository, while a commit SHA cannot. Pinning matters most for third-party actions, but the rule is the same for all of them.
Why is github.head_ref an error when github.ref_name is only a note?
github.head_ref is the source branch of a pull request, and whoever opens the pull request names it. In a pull_request_target run that can be a stranger with a fork and no access to your repository, so it is reported as an error next to the pull request title. github.ref_name in a pull_request run is N/merge, which the author does not control; in a push it is a branch that someone with write access created, and a workflow_dispatch input comes from someone who can start the run, so both are notes.
Can it check a reusable workflow that another file calls?
Open that file separately. A workflow with on: workflow_call is checked like any other, including the inputs it declares for use in expressions.