Skip to main content

SKY-D304 · CI/CD pipelines

Bot check on a spoofable actor

Medium

The catalog lists MEDIUM, but the detector reports every finding as HIGH.

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

.github/workflows/automerge.yml · YAMLReported on line 9
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

.github/workflows/automerge.yml · YAML
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

  1. Reads the if: of every job and step in workflow files (not composite actions).
  2. Reports a condition where github.actor, github.triggering_actor, github.actor_id, or github.event.pull_request.sender.login or .id, is followed later on the same line by [bot] or by one of the bot account IDs 29110, 49699333, 27856297 or 29139614.
  3. The comparison operator is not read, so != is reported too. The bot name must come after the context: 'dependabot[bot]' == github.actor is not reported, and neither is github.event.sender.login.
  4. 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.

.github/workflows/automerge.yml · YAML · the fix, against the flagged file
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.sender is 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_target trigger.

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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.