Skip to content

CI: Harden GHA configuration#102

Merged
dstansby merged 8 commits into
matplotlib:mainfrom
tacaswell:harden_gha
Sep 27, 2025
Merged

CI: Harden GHA configuration#102
dstansby merged 8 commits into
matplotlib:mainfrom
tacaswell:harden_gha

Conversation

@tacaswell
Copy link
Copy Markdown
Member

Apply recommended hardening steps including:

  • pinning to a SHA any actions used
  • not persisting the read token on checkout
  • setting the default permissions
  • adding a depandabot file for GHA

This eliminates the possibility of a tag being changed under
us.
This eliminates the possibility of a tag being changed under
us.
May include:

- Avoids risky string interpolation.
- Prevents checkout premissions from leaking
Reduces risk of arbitrary code is run by attacker.
Reduces risk of arbitrary code is run by attacker.
Comment thread .github/workflows/main.yaml Outdated
contents: write

steps:
- uses: actions/checkout@v4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not pinned.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No actions are pinned in this file.

@tacaswell
Copy link
Copy Markdown
Member Author

The tool I used to find un-pinned actions (zizmor) does not flag the "official" action/xyz actions.

I suspect the logic is if someone manages to compromise GH there are more direct ways to cause trouble than funny side-band attacks via GHA.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Jul 24, 2025

I think you need to run with the pedantic persona to catch those.

Copy link
Copy Markdown
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Since even without pinning the actions/* workflows this is an improvement, I will merge.

@dstansby dstansby merged commit 7d4746e into matplotlib:main Sep 27, 2025
3 checks passed
@tacaswell tacaswell deleted the harden_gha branch September 29, 2025 14:23
@tacaswell
Copy link
Copy Markdown
Member Author

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Sep 29, 2025

Yes, it looks like it should have statuses permission, not the others: https://github.com/scientific-python/circleci-artifacts-redirector-action?tab=readme-ov-file#example-usage

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