ci: declare workflow-level contents: read on 2 workflows - #14331
Conversation
Pins the default GITHUB_TOKEN to contents: read on workflows that don't call a GitHub API beyond the initial checkout. Other workflows that need write scopes are left implicit for a maintainer to declare. Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files compromise) exfiltrated GITHUB_TOKEN from workflow logs. Per-workflow caps bound runtime authority irrespective of repo or org default, give drift protection, and are credited per-file by the OpenSSF Scorecard Token-Permissions check. YAML validated locally with yaml.safe_load. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
This pull request does not have a backport label. Could you fix it @arpitjain099? 🙏
|
|
Can you elaborate a bit more on why you want to pin the permissions at workflow level in these specific workflows? Are these the only readonly ones we have? |
|
Hi @swiatekm, sure. Both workflows just do On scope: I audited all 42 workflows. 39 already pin permissions. These 2 plus Whichever backport branch fits, just let me know or label it yourselves. |
|
@arpitjain099 thanks for explaining! I think we should cover the third workflow as well, if we can do so without losing functionality. I'll take care of the backport labels. |
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
|
Permissions should be granted always at the job level in case they need any write access or other scopes. I like the principle of least-permissive access by default, thanks for this. |
|
buildkite test this |
💛 Build succeeded, but was flaky
Failed CI Steps |
|
@Mergifyio backport 9.4 9.3 8.19 |
✅ Backports have been createdDetails
Cherry-pick of 5bebb64 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
…on 2 workflows (#14388) * ci: declare workflow-level contents: read on 2 workflows (#14331) Pins the default GITHUB_TOKEN to contents: read on workflows that don't call a GitHub API beyond the initial checkout. Other workflows that need write scopes are left implicit for a maintainer to declare. Motivation: CVE-2025-30066 (March 2025 tj-actions/changed-files compromise) exfiltrated GITHUB_TOKEN from workflow logs. Per-workflow caps bound runtime authority irrespective of repo or org default, give drift protection, and are credited per-file by the OpenSSF Scorecard Token-Permissions check. YAML validated locally with yaml.safe_load. Signed-off-by: Arpit Jain <arpitjain099@gmail.com> (cherry picked from commit 5bebb64) # Conflicts: # .github/workflows/validate-docs-structure.yml * Delete .github/workflows/validate-docs-structure.yml --------- Co-authored-by: Arpit Jain <3242828+arpitjain099@users.noreply.github.com> Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
Pins the default
GITHUB_TOKENtocontents: readon 2 workflows in.github/workflows/that don't call a GitHub API beyond the initial checkout.Why
CVE-2025-30066 (March 2025
tj-actions/changed-filessupply-chain compromise) exfiltratedGITHUB_TOKENfrom workflow logs. Pinning per workflow caps runtime authority irrespective of the repo or org default, gives drift protection if the default ever widens, and is credited per-file by the OpenSSF ScorecardToken-Permissionscheck.YAML validated locally with
yaml.safe_loadon each touched file.