Skip to content

Harden gh actions workflows - #3759

Merged
ankith26 merged 1 commit into
mainfrom
ankith26-zizmor
Apr 5, 2026
Merged

ankith26 merged 1 commit into
mainfrom
ankith26-zizmor

Conversation

@ankith26

Copy link
Copy Markdown
Member

After learning about the recent litellm security incident (TL;DR: supply chain attack via github actions, the PyPI token of a popular library was leaked to attackers who released bad releases that then compromised user creds and so on) I was prompted into further scrutinizing our own actions for security.

The good news is that we are already pretty secure in terms of PyPI publishing. We don't use a static PyPI token and instead use the recommended Trusted PyPI Publisher approach for managing our releases. So an attack like the above mentioned case wouldn't be possible with us.

But still, to be cautious (using zizmor for github actions static analysis) this PR identifies and fixes a couple of security gotchas, mainly under three categories:

  • Pins all actions to hashes instead of versions (this secures us against potential malicious upstream releases that re-use old tags). Dependabot is capable of keeping these hashes updated as hashes.
  • Explicit content read-only permissions for all actions (this secures us against actions making writes to the repo)
  • Checkout without persisting git credentials

@ankith26
ankith26 requested a review from a team as a code owner March 28, 2026 07:57
@coderabbitai

coderabbitai Bot commented Mar 28, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c1611c08-803f-486e-bbf0-a4fd928e9977

📥 Commits

Reviewing files that changed from the base of the PR and between 57012c3 and 4329d03.

📒 Files selected for processing (12)
  • .github/dependabot.yml
  • .github/workflows/build-debian-multiarch.yml
  • .github/workflows/build-emsdk.yml
  • .github/workflows/build-macos.yml
  • .github/workflows/build-manylinux.yml
  • .github/workflows/build-sdl3.yml
  • .github/workflows/build-ubuntu-sdist.yml
  • .github/workflows/build-windows.yml
  • .github/workflows/dev-check.yml
  • .github/workflows/release-gh-draft.yml
  • .github/workflows/release-pypi.yml
  • .github/workflows/run-ubuntu-checks.yml
✅ Files skipped from review due to trivial changes (2)
  • .github/workflows/build-manylinux.yml
  • .github/workflows/run-ubuntu-checks.yml
🚧 Files skipped from review as they are similar to previous changes (7)
  • .github/dependabot.yml
  • .github/workflows/dev-check.yml
  • .github/workflows/build-debian-multiarch.yml
  • .github/workflows/release-pypi.yml
  • .github/workflows/release-gh-draft.yml
  • .github/workflows/build-macos.yml
  • .github/workflows/build-sdl3.yml

📝 Walkthrough

Walkthrough

Workflows and Dependabot config updated: Dependabot gains a 7-day cooldown; many GitHub Actions workflows add explicit permissions: contents: read, pin action references to commit SHAs, set persist-credentials: false on checkouts, and add/adjust concurrency or remove checkout steps in release workflows.

Changes

Cohort / File(s) Summary
Dependabot Configuration
.github/dependabot.yml
Added cooldown with default-days: 7 for GitHub Actions updates to control Dependabot retry/eligibility timing.
Build Workflows (general)
.github/workflows/build-*.yml
.github/workflows/build-debian-multiarch.yml, .../build-emsdk.yml, .../build-macos.yml, .../build-manylinux.yml, .../build-sdl3.yml, .../build-ubuntu-sdist.yml, .../build-windows.yml
Added workflow-level permissions: contents: read; pinned many uses: action references to specific commit SHAs (checkout, cache, upload/download-artifact, cibuildwheel, setup-python, msys2/setup-msys2, etc.); set with.persist-credentials: false on actions/checkout; changed concurrency group suffix in SDL3 workflow.
CI / Dev Check Workflows
.github/workflows/dev-check.yml, .github/workflows/run-ubuntu-checks.yml
Added permissions: contents: read; pinned actions/checkout to SHAs and set persist-credentials: false; pinned other actions (actions/cache, actions/upload-artifact) where present; adjusted PR diff base reference in run-cppcheck.
Release Workflows
.github/workflows/release-gh-draft.yml, .github/workflows/release-pypi.yml
Added concurrency to enforce single in-flight release per ref; added permissions: contents: read; removed actions/checkout from some publish jobs; pinned external action references to specific commit SHAs (download-artifact, attest-build-provenance, gh-release, release-downloader, gh-action-pypi-publish).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Harden gh actions workflows' is concise and clearly describes the main change—security hardening of GitHub Actions workflows through pinning, permissions, and credential handling.
Description check ✅ Passed The description thoroughly explains the motivation (litellm security incident), current security posture, and the specific hardening measures implemented across all changed files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ankith26-zizmor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build-debian-multiarch.yml:
- Around line 38-40: The workflow's permissions block only grants contents: read
but the uraimo/run-on-arch-action steps use githubToken to cache GHCR images;
update the permissions block (the top-level permissions: mapping) to include
packages: write and packages: read so the action can push and pull container
cache layers when the install step runs; locate the permissions block in the
workflow and add the two packages entries alongside contents: read.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0d06e897-f44b-485b-9c89-a5abe40cd455

📥 Commits

Reviewing files that changed from the base of the PR and between 56d41ff and 57012c3.

📒 Files selected for processing (12)
  • .github/dependabot.yml
  • .github/workflows/build-debian-multiarch.yml
  • .github/workflows/build-emsdk.yml
  • .github/workflows/build-macos.yml
  • .github/workflows/build-manylinux.yml
  • .github/workflows/build-sdl3.yml
  • .github/workflows/build-ubuntu-sdist.yml
  • .github/workflows/build-windows.yml
  • .github/workflows/dev-check.yml
  • .github/workflows/release-gh-draft.yml
  • .github/workflows/release-pypi.yml
  • .github/workflows/run-ubuntu-checks.yml

@oddbookworm oddbookworm left a comment

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.

This seems fine to me

@damusss damusss added the github_actions Pull requests that update GitHub Actions code label Mar 31, 2026
@ankith26 ankith26 added this to the 2.5.8 milestone Apr 2, 2026

@Starbuck5 Starbuck5 left a comment

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.

Did you mean to add permissions to build-manylinux as well?

Otherwise happy to go with this, thanks for checking it out Ankith.

@ankith26

ankith26 commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

build-manylinux already has permissions defined but at the job level not workflow level. This is fine for now because the workflow has only one job defined but this can be changes in the future.

@ankith26
ankith26 merged commit d4bcae1 into main Apr 5, 2026
34 checks passed
@ankith26
ankith26 deleted the ankith26-zizmor branch April 5, 2026 04:09
@coderabbitai coderabbitai Bot mentioned this pull request Jun 28, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants