Skip to content

security.yml: gitleaks fails every pull request because GITHUB_TOKEN is not passed #2740

Closed

Description

@drpaulobernardy

What happens

.github/workflows/security.yml runs gitleaks/gitleaks-action on pull_request, but the step does not pass GITHUB_TOKEN. On every pull request the action stops before scanning any commit:

🛑 GITHUB_TOKEN is now required to scan pull requests.

So the secret scan fails on every PR, whatever the PR contains, and a red check that is always red stops meaning anything.

Seen where

A private copy of the repo, on release 8.761.0's security.yml, across four consecutive PRs. Push events to main are not affected, since the action only needs the token for pull_request.

What fixed it there

Two additions, each made after the error it answers:

permissions:
  contents: read
  pull-requests: read   # with only contents: read, the action stopped at "Resource not accessible by integration" while listing the PR's commits

      - name: Run gitleaks
        uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

With both, the secret scan passes on PRs. I have not checked whether a public repo also needs pull-requests: read; the GITHUB_TOKEN requirement comes from the action itself (see its README usage example).

Activity

  1. alexisromtz-lab commented on Nov 11, 2026

    @alexisromtz-lab

    Answering the open question at the end, because the file settles it — security.yml @ f6ab5e0228bfb356c82edbf52b69344dbd585486.

    Yes, the public repo needs pull-requests: read too, and the reason is stronger than the private case. security.yml:13-14 already declares an explicit block:

    permissions:
      contents: read

    Once a workflow declares permissions: at all, every scope it does not list is set to none for that run — it does not fall back to the repository or organisation default. So pull-requests is none by construction here, and it would be none even if the repository default were permissive. The public/private question does not enter into it: the block is in the file, not in the policy.

    Which means the two additions you made in the private copy are both required, at these loci:

    • security.yml:13-14 — add pull-requests: read next to contents: read.
    • security.yml:28 — add GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} to the env: of the Run gitleaks step. The action needs the token to enumerate the PR commits, and the env: at :28-32 currently carries only GITLEAKS_ENABLE_UPLOAD_ARTIFACT and GITLEAKS_VERSION.

    What does not need to change. The rest of the workflow is already in the shape you would want for a public repo:

    • All four uses: are SHA-pinned with the tag as a comment — actions/checkout@11d5960a…:22, gitleaks/gitleaks-action@ff98106e…:27, actions/checkout@11d5960a…:39, oven-sh/setup-bun@0c5077e5…:44.
    • SENSITIVE_TERMS reaches the scan through env: at :55, not interpolated into the run: string at :49. That is the distinction that matters for a secret in a public workflow, and it is already on the right side of it — so correcting the gitleaks gate does not put it at risk.
    • The sensitive-content job at :34 declares no permissions: of its own; it inherits the root contents: read, which is all it needs.

    One adjacent observation, since it is the same class of problem and it is not in this file: the only floating refs left in the repo are in .github/workflows/claude-code-review.yml and .github/workflows/claude.yml — actions/checkout@v4 and anthropics/claude-code-action@v1 in each. Everything a pull_request triggers is pinned; the two workflows that hold a mutable ref are the ones that are not part of this gate.

    Nothing changed on my side; this is read-only measurement of the public tree.

  2. danielmiessler commented on Nov 18, 2026

    @danielmiessler
    Owner

    Note

    🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

    Thanks @drpaulobernardy, you found that security.yml runs gitleaks on pull requests without GITHUB_TOKEN, so it fails every PR. Our release check now flags a token-less gitleaks job, and the workflow file itself gets the token and the pull-requests permission as part of the next release.

    This fix lands in the next LifeOS release, so I'm closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions