fix(ci): do not persist the job token in .git/config in the public-repo guard - #27
fix(ci): do not persist the job token in .git/config in the public-repo guard#27yakimoto wants to merge 1 commit into
Conversation
…po guard actions/checkout without persist-credentials:false leaves GITHUB_TOKEN readable in .git/config for every later step — including the one that downloads and executes the gitleaks binary. Nothing in this job uses the credential (contents:read, gitleaks runs --no-git, no gh/push steps). Refs #1870.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_cc717a75-e326-47d6-9e26-23f80138a922) |
ApprovabilityVerdict: Approved 92dd382 Minor CI/CD security hardening that adds You can customize Macroscope's approvability policy. Learn more. |
PR Summary by QodoHarden public-repo-guard checkout by disabling credential persistence
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
| with: | ||
| persist-credentials: false |
There was a problem hiding this comment.
🟡 Shared copy of the security-gate workflow still leaves the job credential on disk
The hardening step that stops the job's credential from being written to disk (persist-credentials: false at .github/workflows/public-repo-guard.yml:46-47) was added only to this repo's own copy and not to the shared template other repositories install from, so every repo that copies the gate keeps the old, unhardened behavior.
Impact: Repos adopting the published guard template continue to expose the build credential to later steps, so the fix does not actually reach the repos it was meant to protect.
Divergence between the live workflow and the vendored workflow template
workflow-templates/public-repo-guard.yml is the copy the org's "install on a new repo" flow uses (the header at .github/workflows/public-repo-guard.yml:16-19 instructs copying the workflow file alongside .gitleaks.toml and scripts/public-repo-guard/content-policy.sh). A diff of the two files shows the only difference is the two newly added lines; workflow-templates/public-repo-guard.yml:45 still has a bare - uses: actions/checkout@... with no with: block.
Prompt for agents
The PR adds `with: persist-credentials: false` to the checkout step in .github/workflows/public-repo-guard.yml but the identical vendored copy at workflow-templates/public-repo-guard.yml (the file other repos install) was not updated. Apply the same change there so the two stay in sync; also consider whether the other workflow templates that call actions/checkout need the same hardening.
Was this helpful? React with 👍 or 👎 to provide feedback.
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | ||
| with: | ||
| persist-credentials: false |
There was a problem hiding this comment.
🔍 Same hardening missing on other org workflows using checkout
A repo-wide grep shows persist-credentials appears only in the file changed by this PR. Other workflows (.github/workflows/issue-ops-triage.yml, .github/workflows/ticket-hygiene.yml) and several workflow-templates/*.yml also use actions/checkout without it. Some of those legitimately need the token, but a follow-up sweep would make the hardening consistent org-wide.
Was this helpful? React with 👍 or 👎 to provide feedback.
| with: | ||
| persist-credentials: false |
There was a problem hiding this comment.
🟨 Distributed guard workflow template still persists the job credential in .git/config
The hardening (persist-credentials: false) was applied only to .github/workflows/public-repo-guard.yml:46-47; the vendored copy at workflow-templates/public-repo-guard.yml:45, which is the version other repositories install, still checks out with credentials persisted. Any repo using that template continues to leave GITHUB_TOKEN readable in .git/config for subsequent steps, including the step that downloads and executes the gitleaks binary.
Was this helpful? React with 👍 or 👎 to provide feedback.
Qodo FixerNo findings are available for this PR yet. Findings appear here once Qodo has reviewed the PR. |
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 3/5
- In
workflow-templates/public-repo-guard.yml, thepersist-credentials: falsehardening is still missing, so repositories that install from this template could inherit the old behavior and unintentionally expose checkout credentials in CI runs—mirror the fix from.github/workflows/public-repo-guard.ymlinto the vendored template to prevent propagation.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/public-repo-guard.yml">
<violation number="1" location=".github/workflows/public-repo-guard.yml:47">
P2: The credential-persistence fix (persist-credentials: false) was added here but the vendored template at workflow-templates/public-repo-guard.yml, which other repositories copy when installing this guard, still has a bare `actions/checkout` step with no `with:` block. Repos that install from that template will continue to leave GITHUB_TOKEN in `.git/config` for the same gitleaks-download step this PR is hardening. Apply the same `persist-credentials: false` change to workflow-templates/public-repo-guard.yml.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| steps: | ||
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | ||
| with: | ||
| persist-credentials: false |
There was a problem hiding this comment.
P2: The credential-persistence fix (persist-credentials: false) was added here but the vendored template at workflow-templates/public-repo-guard.yml, which other repositories copy when installing this guard, still has a bare actions/checkout step with no with: block. Repos that install from that template will continue to leave GITHUB_TOKEN in .git/config for the same gitleaks-download step this PR is hardening. Apply the same persist-credentials: false change to workflow-templates/public-repo-guard.yml.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/public-repo-guard.yml, line 47:
<comment>The credential-persistence fix (persist-credentials: false) was added here but the vendored template at workflow-templates/public-repo-guard.yml, which other repositories copy when installing this guard, still has a bare `actions/checkout` step with no `with:` block. Repos that install from that template will continue to leave GITHUB_TOKEN in `.git/config` for the same gitleaks-download step this PR is hardening. Apply the same `persist-credentials: false` change to workflow-templates/public-repo-guard.yml.</comment>
<file context>
@@ -43,6 +43,8 @@ jobs:
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
+ with:
+ persist-credentials: false
# gitleaks' GitHub Action requires a paid license for organizations; the CLI
</file context>
|
This PR is redundant with #23 ( Evidence — #23's diff to + # tree. Nothing here pushes -- the scan is `--no-git` over the working tree --
+ # so no step needs authenticated Git; drop it. (zizmor: artipacked)
+ persist-credentials: false#23 is also broader than this PR: it syncs the whole vendored Closing as redundant. This duplicate exists because the fan-out that opened this PR |
Why
actions/checkoutwithoutpersist-credentials: falsewrites the job's GITHUB_TOKEN into.git/config, where any later step — or anything those steps execute — can read it. This is thesecurity gate that DOWNLOADS AND EXECUTES the gitleaks binary, and the workflow's own comment
already reasons about tampered downloads ("so a tampered or MITM'd download can never execute
inside the security gate"), so the threat model is written down and only the credential half of
the mitigation is missing. Found by zizmor as
warning[artipacked]: credential persistence through GitHub Actions artifacts.Safety
Verified this job only: checks out, installs gitleaks (pinned + checksum), runs
gitleaks detect --no-git, installs ripgrep, runscontent-policy.sh.permissions: contents: read. Nothing pushes, callsgh, or reads GITHUB_TOKEN/GH_TOKEN, so the token was never neededin
.git/configin the first place.Refs wave-av/claude-workstation#1870.
Note
Low Risk
Single workflow security hardening with no change to scan logic or permissions; reduces credential exposure without affecting functionality.
Overview
Hardens the public-repo-guard workflow by setting
persist-credentials: falseonactions/checkout, so the job token is not stored in.git/configfor later steps or anything they run.This aligns with the workflow’s existing threat model (pinned, checksum-verified gitleaks download): the job only reads the tree and runs scans with
contents: read, so persisted credentials were unnecessary exposure.Reviewed by Cursor Bugbot for commit 92dd382. Configure here.