SKY-D304 · CI/CD pipelines
Bot check on a spoofable actor
github.actor is the account that caused the latest event, not the author of the pull request. A condition such as github.actor == 'dependabot[bot]' is often used to auto-approve or auto-merge bot pull requests. SKY-D304 reports conditions that recognise a bot through the actor.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions spoofable bot condition
Why it matters
Published attacks get Dependabot to push to a branch the attacker controls, so the event on the attacker's pull request names Dependabot as its actor. The check passes, and a job with write access merges or runs the attacker's code.
What Skylos flags
name: Dependabot auto-mergeon: pull_request_targetpermissions: contents: write pull-requests: writejobs: automerge: runs-on: ubuntu-latest if: github.actor == 'dependabot[bot]' steps: - run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ github.token }}What Skylos leaves alone
name: Dependabot auto-mergeon: pull_request_targetpermissions: contents: write pull-requests: writejobs: automerge: runs-on: ubuntu-latest if: github.event.pull_request.user.login == 'dependabot[bot]' steps: - run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ github.token }}Why Skylos leaves it alone
The condition checks who opened the pull request, which does not change when someone else causes a later event on it. GitHub's Dependabot documentation uses this check.
How Skylos decides
- Reads the
if:of every job and step in workflow files (not composite actions). - Reports a condition where
github.actor,github.triggering_actor,github.actor_id, orgithub.event.pull_request.sender.loginor.id, is followed later on the same line by[bot]or by one of the bot account IDs 29110, 49699333, 27856297 or 29139614. - The comparison operator is not read, so
!=is reported too. The bot name must come after the context:'dependabot[bot]' == github.actoris not reported, and neither isgithub.event.sender.login. - One HIGH finding per condition, on the first line of the file that holds the condition's first line.
How to fix it
Check the author of the pull request instead of the actor. For auto-merge, dependabot/fetch-metadata can also limit merges to patch and minor updates.
name: Dependabot auto-mergeon: pull_request_targetpermissions: contents: write pull-requests: writejobs: automerge: runs-on: ubuntu-latestRemoved: if: github.actor == 'dependabot[bot]'Added: if: github.event.pull_request.user.login == 'dependabot[bot]' steps: - run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ github.token }}When it can be wrong
if: github.actor != 'dependabot[bot]', which skips a job for bot pull requests and grants nothing, is reported.github.event.pull_request.senderis not a field GitHub sends, so that part of the pattern never matches real workflows, while the real sender field,github.event.sender.login, is not checked.- The flagged example also gets SKY-D290 for its
pull_request_targettrigger.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put
# skylos: ignore[SKY-D304]on the reported line or on the line directly above it, one rule per marker.YAML # skylos: ignore[SKY-D304] only skips the job for bot pull requestsif: github.actor != 'dependabot[bot]'[tool.skylos] ignore = ["SKY-D304"]turns the rule off for the whole project.A baseline works, but it records the absolute file path and the line, so it stops matching when the checkout moves or lines above shift.