SKY-D302 · CI/CD pipelines
GitHub App token broader than needed
actions/create-github-app-token turns a GitHub App's private key into a short-lived token for a job. SKY-D302 reports three ways that token ends up stronger than the job needs: it covers every repository of an owner, it keeps every permission the app was installed with, or it is not revoked when the job ends.
- Languages
- GitHub Actions workflows, composite actions
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions broad GitHub App token
Why it matters
Anything that runs later in the job, including a compromised action or build tool, can read the token. A token for one repository with contents: write limits the damage to that repository; an owner-wide token with all the app's permissions can rewrite code across the organisation.
What Skylos flags
name: Update Homebrew tapon: release: types: [published]permissions: contents: readjobs: tap: runs-on: ubuntu-latest steps: - name: Get a token for the tap repository id: app-token uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.RELEASE_BOT_APP_ID }} private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} owner: acme permission-contents: write - name: Bump the formula run: gh workflow run bump.yml --repo acme/homebrew-tap -f tag="$TAG" env: GH_TOKEN: ${{ steps.app-token.outputs.token }} TAG: ${{ github.event.release.tag_name }}What Skylos leaves alone
name: Create the releaseon: workflow_dispatch:permissions: contents: readjobs: tag: runs-on: ubuntu-latest steps: - name: Get a token for this repository id: app-token uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.RELEASE_BOT_APP_ID }} private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} permission-contents: write - name: Create the release run: gh release create "v$VERSION" --repo "$GITHUB_REPOSITORY" --generate-notes env: GH_TOKEN: ${{ steps.app-token.outputs.token }} VERSION: ${{ vars.NEXT_VERSION }}Why Skylos leaves it alone
There is no owner:, so the action limits the token to the repository running the workflow, and a permission-contents input limits it to that one permission. It is revoked when the job ends.
How Skylos decides
- Reads the steps of workflows and of composite actions (
action.yml) whoseuses:isactions/create-github-app-token, at any version. - Reports
skip-token-revokeset to true (true,yes,on,1): the token stays valid after the job, until it expires. - Reports
owner:withoutrepository:orrepositories:: the token reaches every repository the app is installed on for that owner. - Reports a step with no input whose name starts with
permission-: the token gets every permission of the app installation. - Each is a HIGH finding, placed on the first line of the file that contains
skip-token-revoke,owner, or the step'suses:value respectively. Two steps with the same problem in one file share that line and give one finding.
How to fix it
Name the repositories the token is for. Keep one permission-* input per permission the job uses, and leave skip-token-revoke unset.
name: Update Homebrew tapon: release: types: [published]permissions: contents: readjobs: tap: runs-on: ubuntu-latest steps: - name: Get a token for the tap repository id: app-token uses: actions/create-github-app-token@v1 with: app-id: ${{ vars.RELEASE_BOT_APP_ID }} private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} owner: acmeAdded: repositories: homebrew-tap permission-contents: write - name: Bump the formula run: gh workflow run bump.yml --repo acme/homebrew-tap -f tag="$TAG" env: GH_TOKEN: ${{ steps.app-token.outputs.token }} TAG: ${{ github.event.release.tag_name }}When it can be wrong
- A job that really works across all of an owner's repositories, such as one that syncs labels everywhere, is reported for its
owner:alone. - The
ownerfinding goes on the first line containing the word, which can be an earlierif: github.repository_owner == 'acme'. A marker on theowner:line then does not silence it. - The examples also get SKY-D292 (LOW, hidden from the default list) for the version tag
@v1.
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-D302]on the reported line or on the line directly above it, one rule per marker.YAML # skylos: ignore[SKY-D302] label sync runs on every acme repositoryowner: acme[tool.skylos] ignore = ["SKY-D302"]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.