fleetlint Policy for a fleet of repositories
v0.5
Getting started

ci/no-script-injection

Untrusted event data never reaches a run script

Severitywarning
Tiers1, 2
Stacksany
Scoperoot
Kindexpr
Sourcelibrary v0.2.0
Selected byfleetlint-recommended@v0.2.0

Requirement

In GitHub, Gitea and Forgejo workflows, ${{ }} expressions over data an outsider controls (issue, PR, discussion and comment titles and bodies, commit messages and authors, head_ref and the PR’s head branch or label, page names) never appear inside a run: script or an actions/github-script script:. They are passed through env: and used as quoted shell variables instead.

Why

The expression is pasted into the script before the shell runs it, so a PR titled `"; curl evil | sh

Applies when

workflows().exists(w, ci_kind(w) != "gitlab")

Check

For each item in:

[r'(\$\{\{[^}]*\b(?:github|gitea|forge)\.(?:head_ref|event\.(?:(?:issue|pull_request|discussion)\.(?:title|body)|(?:comment|review|review_comment)\.body|pages(?:\[\d+\]|\.\*)?\.page_name|(?:head_commit|commits(?:\[\d+\]|\.\*)?|workflow_run\.head_commit)\.(?:message|(?:author|committer)\.(?:name|email))|pull_request\.head\.(?:ref|label|repo\.default_branch)|workflow_run\.head_branch))\b[^}]*\}\})'].map(re,
  grep(".github/workflows/*.y*ml", re) + grep(".gitea/workflows/*.y*ml", re) + grep(".forgejo/workflows/*.y*ml", re)).flatten()
item.text.startsWith("#") || (item.text.matches(r'^-?\s*["\x27]?[A-Za-z_][\w-]*["\x27]?:\s*["\x27]?\$\{\{') && !item.text.matches(r'^-?\s*(run|script):')) || !steps(item.path).exists(s, s.run.contains(item.match) || ("script" in s.with && string(s.with.script).contains(item.match)))

Fix

Move each flagged expression into the step’s env: and reference the variable ("$TITLE") in the script.

Agent instruction: For every flagged line, add an env entry on the step holding the expression and replace the expression in the run/script body with the quoted environment variable; change nothing else.

See: https://fleetlint.org/baseline/#security


Generated by fleetlint docs from catalog v0.2.0.