Security rules
NGB095: Untrusted artifact in a privileged workflow
Reports workflow_run workflows that download artifacts produced by the triggering run (actions/download-artifact with run-id: ${{ github.event.workflow_run.id }}, dawidd6/action-download-artifact, github-script artifact APIs, gh run download) — with high confidence when a later step of the same job runs commands that can consume them..
| Property | Value |
|---|---|
| Rule ID | NGB095 |
| Category | Supply chain |
| Default severity | high |
| CWE | CWE-829, CWE-494 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports workflow_run workflows that download artifacts produced by the triggering run (actions/download-artifact with run-id: ${{ github.event.workflow_run.id }}, dawidd6/action-download-artifact, github-script artifact APIs, gh run download) — with high confidence when a later step of the same job runs commands that can consume them.
Why it matters
workflow_run lets a privileged workflow (secrets, write token) react to an unprivileged pull_request run. The artifacts of that run were produced by contributor-controlled code: a fork can upload a crafted archive that overwrites scripts, package.json, or files later sourced into $GITHUB_ENV, turning the privileged workflow into a code-execution primitive ("artifact poisoning").
Detection behavior and supported patterns
on: workflow_runworkflows only- Download steps listed above; high confidence when a later
run:step exists in the same job, medium otherwise
Example
on: workflow_run: workflows: [CI] types: [completed]jobs: comment: steps: - uses: actions/download-artifact@v4 with: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GITHUB_TOKEN }} - run: bash ./report.shSafer alternative
- uses: actions/download-artifact@v4 with: run-id: ${{ github.event.workflow_run.id }} path: ${{ runner.temp }}/pr - run: jq -e '.number | numbers' "$RUNNER_TEMP/pr/meta.json"Remediation
Treat downloaded artifacts as untrusted input: extract into a temporary directory outside the workspace, never execute or source their content, validate any values (e.g. a PR number must be numeric) before use, and keep the privileged job's permissions minimal.
False-positive considerations
- Workflows that extract artifacts into an isolated directory (
path: ${{ runner.temp }}/artifacts) and only read validated data from it are reported with the same severity; document the validation in an exception.
Known limitations
- Whether the artifact content is treated strictly as data (e.g. only parsed as JSON and validated) is not analyzed.
- Artifacts downloaded in one job and used in another are reported at the download step only.
References
Run it
ngbastion explain NGB095