Untrusted Input in CI/CD Workflows
A CI/CD workflow puts attacker-controllable data, such as pull request titles or branch names, into scripts it runs, or runs untrusted code with access to secrets.
| Severity | High |
| CVSS 3.1 | 8.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N Open in the calculator |
| CVSS 4.0 | 8.6 CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-94: Improper Control of Generation of Code ('Code Injection') |
| OWASP Top 10 | A05:2025 Injection |
| MITRE ATT&CK | T1677 Poisoned Pipeline Execution, T1195.002 Compromise Software Supply Chain |
| Category | Injection |
Description
A CI/CD pipeline handles data or code from people outside the trusted team in a way that lets them run commands on the build runner with the workflow's permissions. The most common form in GitHub Actions is script injection: a workflow inserts an expression that reads event data, such as github.event.issue.title, github.event.pull_request.title or github.head_ref, directly into a run: step. The expression is substituted into the script before the shell runs it, so a title or branch name containing shell syntax becomes part of the command. The same pattern occurs on other platforms wherever commit messages, merge request details or other event data are interpolated into scripts.
A second form, often called a pwn request, is a workflow triggered by pull_request_target or workflow_run, which runs in the context of the base repository with access to its secrets and, depending on settings, a token that can write to it, and which checks out and builds code from an untrusted pull request, so that build scripts, tests or package install hooks written by the contributor run with those privileges. Self-hosted runners that accept jobs from untrusted pull requests carry a similar risk.
The attacker can typically read every secret available to the job, such as cloud credentials, package registry tokens and deployment keys, and, where the workflow token has write permissions, use it to push code or create releases. Where the pipeline publishes packages, container images or releases, they can insert malicious code into software that customers or other teams install, turning one injection into a supply chain compromise. In public repositories anyone with an account on the platform can usually open an issue or pull request, which raises the severity considerably; in private repositories the attacker needs to be, or to have compromised, a contributor.
The weakness is identified by reviewing workflow definitions, with tools such as zizmor, actionlint or CodeQL's workflow queries, for event data used inside scripts and for privileged triggers that check out untrusted code. Where in scope, it can be confirmed by opening an issue or pull request whose title contains a harmless marker command and observing it in the workflow log.
Remediation
Treat all event data and contributed code as untrusted in every workflow:
- Never interpolate event data directly into scripts. Pass it to the step through an
env:entry and refer to it in the script as a quoted shell variable, such as"$TITLE", so that the shell treats it as data rather than code. - Avoid
pull_request_targetandworkflow_runfor jobs that check out or build code from pull requests. Build untrusted code with the unprivilegedpull_requesttrigger, and keep privileged steps, such as commenting or publishing, in separate jobs that do not run contributed code. - Set the workflow token's
permissionsto read-only by default and grant write scopes only to the jobs that need them. - Require approval before workflows run for pull requests from outside contributors, and do not use self-hosted runners for public repositories or untrusted pull requests.
- Add a workflow linter such as zizmor or actionlint to the repository's checks so that new injection points are flagged before they are merged.
Where a vulnerable workflow may already have been triggered by an outsider, rotate the secrets it could reach and review recent releases and commits made by the pipeline. Confirm the fix by reviewing every workflow for remaining event data in scripts and privileged triggers, and by repeating the marker test.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.