Skip to content

Improve GitHub Actions security with token restrictions#2

Open
Herklos wants to merge 2 commits intomasterfrom
claude/secure-github-actions-5voyl
Open

Improve GitHub Actions security with token restrictions#2
Herklos wants to merge 2 commits intomasterfrom
claude/secure-github-actions-5voyl

Conversation

@Herklos
Copy link
Member

@Herklos Herklos commented Mar 5, 2026

Summary

Restrict GitHub Actions GITHUB_TOKEN to read-only by default and add security notes about workflow pinning.

Changelog

  • Add permissions: read-all at workflow level to restrict GITHUB_TOKEN to read-only access by default
  • Explicitly declare contents: read permission for the publish job
  • Add security notes documenting the @master pinning concern in reusable workflows
  • Include guidance for migrating to version tags once available in Drakkar-Software/.github

What's new?

This PR enhances the security posture of the GitHub Actions workflow by implementing the principle of least privilege for token permissions:

  1. Default read-only permissions: The workflow now sets permissions: read-all at the top level, restricting the GITHUB_TOKEN to read-only access for all jobs by default. This prevents accidental or malicious token misuse.

  2. Explicit permission declaration: The publish job explicitly declares the contents: read permission it needs, making the permission requirements transparent and auditable.

  3. Security documentation: Added SECURITY NOTE comments documenting the risk of pinning reusable workflows to @master, which can be silently changed via force-push. These notes include guidance for migrating to version tags once they become available in the Drakkar-Software/.github repository.

These changes follow GitHub's security best practices for workflow token management and improve the overall security of the CI/CD pipeline.

https://claude.ai/code/session_01CHRbcdCqJVRaXuhD7v2Chg

claude added 2 commits March 5, 2026 08:11
- Add `permissions: read-all` at the workflow level to restrict the
  GITHUB_TOKEN to read-only by default for all jobs
- Add `permissions: contents: read` on the publish job as the only
  explicitly needed permission (PyPI upload uses secrets, not GITHUB_TOKEN)
- Flag the two @master-pinned reusable workflows
  (python3_sdist_workflow.yml and failure_notify_workflow.yml) with
  SECURITY NOTEs explaining the risk; Drakkar-Software/.github has no
  version tags yet so the @master refs cannot be replaced with a tag
  at this time — the comments document the remediation path

No functional changes to existing version tags or workflow logic.

https://claude.ai/code/session_01CHRbcdCqJVRaXuhD7v2Chg
Keep the permission hardening but drop the verbose comment blocks
per user request.

https://claude.ai/code/session_01CHRbcdCqJVRaXuhD7v2Chg
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.

3 participants