-
Notifications
You must be signed in to change notification settings - Fork 6
Fix zizmor security issues in GitHub Actions workflows #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds 7-day cooldown period to all Dependabot package ecosystem entries to prevent excessive update frequency and potential supply chain attacks through rapid dependency updates. Detected by: zizmor v1.20.0 (dependabot-cooldown rule)
Prevents Git credentials from being persisted in the workflow environment after checkout, reducing the risk of credential exposure through artifacts or subsequent steps. Affected files: - .github/workflows/labels.yml - .github/workflows/tests.yml (4 checkouts) - .github/workflows/update.yml - check-cla/action.yml Detected by: zizmor v1.20.0 (artipacked rule)
Apply least privilege principle by declaring minimal required permissions for each workflow instead of using default write-all. Detected by: zizmor v1.20.0 (excessive-permissions rule)
Replace direct template expansions with environment variables to prevent potential code injection attacks. Inputs are now passed via env vars which are properly escaped by the shell. Affected files: - canary-release/action.yml - combine-durations/action.yml - create-fork/action.yml - read-file/action.yml - template-files/action.yml - .github/workflows/update.yml Detected by: zizmor v1.20.0 (template-injection rule)
Use process.env and os.environ to access inputs instead of direct template expansion in JavaScript and Python code blocks. Affected files: - set-commit-status/action.yml - read-yaml/action.yml - check-cla/action.yml Detected by: zizmor v1.20.0 (template-injection rule)
Split the CLA workflow into two parts for improved security: 1. cla-trigger.yml: Runs on pull_request_target but only saves PR metadata (number, author, url, sha) to artifacts. No secrets used. 2. cla.yml: Runs on workflow_run after trigger completes. Downloads PR metadata from artifacts and uses secrets safely. This follows the recommended pattern for secure pull_request_target usage by separating untrusted PR context from secret access. Also adds zizmor.yml configuration file with documented suppressions for intentional dangerous trigger usage in: - cla-trigger.yml (saves metadata only, no secrets) - cla.yml (workflow_run with artifact-based PR context) - project.yml (no code checkout, only adds to project)
Permissions for issues:write and pull-requests:write are now defined at the job level (template-files and analyze jobs) rather than workflow level, following least privilege principle.
Use environment variables instead of direct template expansion: - stale.yml: Pass stale action outputs via STALE_OUTPUTS env var - tests.yml: Pass JSON/YAML content via env vars to Python script
for more information, see https://pre-commit.ci
Template SuccessWarning This is what the audit looks like when the templating has no errors. Templating Audit
Template ErrorWarning This is what the audit looks like when templating results in errors. Templating Audit
Got 1 error(s) |
|
The comment above is to be expected because of the change to the |
|
@jezdez any reason not to add zizmor as pre-commit hook via?: |
|
as this is the central repo maybe adding actionlint is also of additional help to find things before they come to the consumers of the actions: |
|
No, these are good ideas, you're right! But adding the actions wouldn't have made these changes |
|
Cannot make changes to the following here (as they're synced from conda/infrastructure):
edit: but I'm starting to wonder if some of the workflows should be synced from here instead, e.g., it makes more sense for the cla workflow to live here alongside the cla action? |
|
Can we combine cla-trigger with cla? Isn't it possible to define permissions per job instead of on the workflow level? |
This PR addresses security issues identified by zizmor in the GitHub Actions workflows.
Changes
persist-credentials: falseto checkout actions where appropriateSecurity Improvements
These changes help protect against: