Skip to content

ci: add persist-credentials: false to checkout steps#10306

Open
knqyf263 wants to merge 2 commits intoaquasecurity:mainfrom
knqyf263:ci/persist-credentials-false
Open

ci: add persist-credentials: false to checkout steps#10306
knqyf263 wants to merge 2 commits intoaquasecurity:mainfrom
knqyf263:ci/persist-credentials-false

Conversation

@knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented Mar 3, 2026

Description

Set persist-credentials: false on actions/checkout steps that don't require git push, preventing the GITHUB_TOKEN from being stored in .git/config and reducing the attack surface for credential theft by compromised dependencies or scripts.

Reference: https://github.com/goreleaser/example-secure/blob/main/.github/workflows/release.yml

Changed workflows (19 checkout steps across 9 files):

  • test.yaml (7 steps)
  • cache-test-assets.yaml (3 steps)
  • publish-chart.yaml (2 steps)
  • release.yaml (2 steps: deploy-packages 1st checkout, update-chart-version)
  • reusable-release.yaml (1 step)
  • scan.yaml (1 step)
  • spdx-cron.yaml (1 step)
  • triage.yaml (1 step)
  • auto-update-labels.yaml (1 step)

Intentionally excluded (require git push):

  • backport.yaml — backport script pushes branches
  • release.yaml trivy-repo checkout — deploy scripts push to trivy-repo
  • mkdocs-dev.yaml / mkdocs-latest.yaml / test-docs.yaml — mike deploys with --push

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Set persist-credentials: false on actions/checkout steps that don't
require git push, preventing the GITHUB_TOKEN from being stored in
.git/config and reducing the attack surface for credential theft.

Checkout steps that require persistent credentials (backport.yaml,
release.yaml trivy-repo checkout, and mkdocs workflows) are
intentionally excluded.
@knqyf263 knqyf263 added the kind/security Categorizes issue or PR as related to Trivy's own security or internal vulnerabilities. label Mar 3, 2026
@knqyf263 knqyf263 self-assigned this Mar 3, 2026
@knqyf263 knqyf263 requested a review from DmitriyLewen March 3, 2026 11:41
@knqyf263 knqyf263 added the autoready Automatically mark PR as ready for review when all checks pass label Mar 3, 2026
@github-actions github-actions bot marked this pull request as ready for review March 3, 2026 12:09
@github-actions github-actions bot removed the autoready Automatically mark PR as ready for review when all checks pass label Mar 3, 2026
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC we will see an error in mage helm:updateVersion.
git push will be failed:

[]string{"git", "push", "origin", newBranch},

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch
#10306

Comment on lines 38 to 41
- name: Checkout trivy-repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.repository_owner }}/trivy-repo
Copy link
Contributor

@DmitriyLewen DmitriyLewen Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Do we want to explicitly specify persist-credentials: true and add a comment for why we need to keep credentials:

     - name: Checkout trivy-repo
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
		with:
			persist-credentials: true # deploy-rpm.sh and deploy-deb.sh require permissions to push changes into trivy-repo
			repository: ${{ github.repository_owner }}/trivy-repo
...

Same for backport.yaml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done
#10306

@knqyf263 knqyf263 enabled auto-merge March 4, 2026 07:25
@knqyf263 knqyf263 disabled auto-merge March 5, 2026 11:50
@knqyf263 knqyf263 enabled auto-merge March 5, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/security Categorizes issue or PR as related to Trivy's own security or internal vulnerabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add persist-credentials: false to GitHub Actions checkout steps

2 participants