-
Notifications
You must be signed in to change notification settings - Fork 66
FXC-3603: security fixes in github actions as suggested by zizmor #2882
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: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 files reviewed, 4 comments
1d14794
to
94bc1d5
Compare
94bc1d5
to
303c5eb
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changesNo lines with coverage information in this diff. |
I have renamed the title of this PR to link to the Zizmor jira task. Are we supposed to link multiple PRs to a single jira issue or should we create a new one everytime? |
- name: install-project | ||
shell: bash | ||
if: ${{ matrix.platform }} != "windows-latest" | ||
if: matrix.platform != 'windows-latest' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I should add: This if-case was always true in the old version due to how github actions works. The new version implements the correct check. It is worthwile to discuss, if we want to remove the if-clause completely, because previously we seemed to test on windows anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daquinteroflex do you know what the reasoning there was? I'd tend toward just removing it, as @mahlau-flex is suggesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mahlau-flex this is great! Besides what was already commented LGTM. I'm not too familiar with the details but as long as everything keeps running it looks fine to me.
|
||
permissions: | ||
contents: read | ||
pull-requests: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain this change? Wouldn't this mean that the scope is now missing from GITHUB_TOKEN
, but there are workflow steps like check-current-approval-status
that do require access to the PR? Would pull-requests: read
do the trick?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this line was, that not all of the jobs need the write permission. Zizmor declared this as a "too broad" permission, so I moved the write permission only to the jobs that actually need it (see line 421 and 520).
Fixed all (except one) of the many security vulnerabilities found by zizmor (12 informational, 0 low, 19 medium, 19 high). While I am pretty sure that the functionality remains the same, we will need to see (an carefully review) if something broke during these changes.
The one issue I could not change is the following (status informational):
I have suppressed the zizmor warning for now. In the long run it would probably be best to use the newer authentication of pypi releases (according to Claude, one can just register a github workflow in pypi instead of using the legacy token system).
Additionally, I have added a pre-commit check for zizmor as well. This might seem a bit excessive, but runs extremely quickly so I think it will not bother anyone.
Lastly, I changed the configuration of zizmor itself in the github actions. I noticed that in the last PR, the job completed successfully, even though it found a security issue. This is, because it uploads the results to github advanced security, which then makes a comment showing the issue. But, this does not prevent merging and is not clearly visibly. With the new system, the checks themselves should (hopefully) fail.
Greptile Overview
Updated On: 2025-10-09 19:03:13 UTC
Summary
This PR implements comprehensive security hardening for GitHub Actions workflows based on findings from the zizmor security scanner, which identified 50 security vulnerabilities (12 informational, 19 medium, 19 high) across the CI/CD pipeline. The changes follow GitHub Actions security best practices without altering functionality.Key security improvements include:
Permission Management: Moving from broad permissions to the principle of least privilege by setting global permissions to
contents: read
and granting specific permissions only where needed (e.g.,contents: write
for jobs that push changes)Action Security: Pinning action versions to specific commit SHAs instead of floating tags to prevent supply chain attacks where malicious code could be injected through compromised action updates
Credential Protection: Adding
persist-credentials: false
to checkout actions to prevent GitHub tokens from being accessible to subsequent workflow steps that don't need themScript Injection Prevention: Moving GitHub context expressions (like PR titles and branch names) to environment variables to prevent potential script injection attacks
Proactive Security: Adding zizmor as both a dependency in
pyproject.toml
and a pre-commit hook to catch future security issues during developmentThe changes span 8 workflow files covering testing, releases, documentation sync, and daily operations. One informational issue regarding PyPI trusted publishing was acknowledged but left unaddressed, with plans to migrate to the newer authentication system in the future. The implementation maintains all existing functionality while significantly reducing the attack surface of the CI/CD pipeline.
Important Files Changed
Changed Files
.github/workflows/tidy3d-python-client-tests.yml
.github/workflows/tidy3d-python-client-release.yml
.github/workflows/tidy3d-python-client-update-lockfile.yml
.github/workflows/tidy3d-python-client-daily.yml
.github/workflows/tidy3d-docs-sync-readthedocs-repo.yml
.github/workflows/tidy3d-python-client-submodules-test.yml
.github/workflows/tidy3d-python-client-develop-cli.yml
.pre-commit-config.yaml
pyproject.toml
Confidence score: 4/5
Sequence Diagram