Skip to content

fix(ci): add least-privilege permissions to workflow files#2944

Draft
waveywaves wants to merge 2 commits intochainloop-dev:mainfrom
waveywaves:fix/scorecard-token-permissions
Draft

fix(ci): add least-privilege permissions to workflow files#2944
waveywaves wants to merge 2 commits intochainloop-dev:mainfrom
waveywaves:fix/scorecard-token-permissions

Conversation

@waveywaves
Copy link
Copy Markdown
Contributor

@waveywaves waveywaves commented Mar 27, 2026

Summary

  • Add top-level permissions blocks to workflow files following the two-tier permission pattern recommended by OpenSSF Scorecard
  • stale.yml: added permissions: {} at workflow level (job-level issues: write + pull-requests: write already correct)
  • build_external_container_images.yaml: moved packages: write from workflow level to job level; set workflow level to permissions: { contents: read }
  • codeql.yml: removed id-token: write from workflow level (kept contents: read); job level already has id-token: write
  • scm_configuration_check.yaml: already had permissions: read-all at workflow level, no change needed

Issue Item Checklist

# File Issue Finding Disposition
1 stale.yml No top-level permissions Fixed: added permissions: {} at workflow level
2 scm_configuration_check.yaml No top-level permissions Already correct: had permissions: read-all at workflow level before this PR
3 build_external_container_images.yaml packages: write at workflow level Fixed: moved packages: write to job level, set workflow level to permissions: { contents: read }
4 release.yaml (issue says github_release.yaml) Job-level packages: write + contents: write No change: legitimate for release workflows; already at job level which is the correct tier
5 package_chart.yaml Job-level packages: write No change: legitimate for chart publishing; already at job level which is the correct tier
bonus codeql.yml id-token: write at workflow level Fixed: removed from workflow level; job already declares id-token: write

Test Plan

  • Verify stale.yml workflow runs correctly (cron or manual dispatch) with the new top-level permissions: {}
  • Verify build_external_container_images.yaml workflow can still build and push container images with packages: write now at job level
  • Verify codeql.yml workflow still generates SLSA provenance with id-token: write only at job level
  • Re-run the OpenSSF Scorecard to confirm the token-permissions score improves

Fixes #2841

@waveywaves waveywaves force-pushed the fix/scorecard-token-permissions branch from 1375beb to 3da776c Compare March 27, 2026 13:33
waveywaves and others added 2 commits March 28, 2026 09:45
Add top-level permissions blocks following the two-tier permission
pattern recommended by OpenSSF Scorecard:

- stale.yml: add `permissions: {}` at workflow level (job already has
  issues: write + pull-requests: write)
- build_external_container_images.yaml: move `packages: write` from
  workflow level to job level; set workflow level to `permissions: read-all`

scm_configuration_check.yaml already had `permissions: read-all` at
workflow level so no change was needed.

Fixes chainloop-dev#2841

Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Replace os.CreateTemp (which generates a random suffix) with a
deterministic filename derived from the config's content hash
(ConfigHash[:12]). This ensures that retries produce the same temp file
path, preventing duplicate CAS uploads when the attestation is retried
due to remote state conflicts.

Fixes: chainloop-dev#2907

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
@waveywaves waveywaves force-pushed the fix/scorecard-token-permissions branch from 3da776c to dcdd23f Compare March 28, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix OpenSSF Scorecard token-permissions check (currently 0/10)

1 participant