Skip to content

ci: fix GitHub Actions security issues found by zizmor#9667

Open
vdemeester wants to merge 3 commits intotektoncd:mainfrom
vdemeester:zizmor-fix-gha-security
Open

ci: fix GitHub Actions security issues found by zizmor#9667
vdemeester wants to merge 3 commits intotektoncd:mainfrom
vdemeester:zizmor-fix-gha-security

Conversation

@vdemeester
Copy link
Copy Markdown
Member

@vdemeester vdemeester commented Mar 26, 2026

Changes

Fix security findings reported by zizmor v1.23.1,
a static analysis tool for GitHub Actions, and add zizmor as a CI check.

Commit 1: Auto-fix findings

  • Add persist-credentials: false to all actions/checkout steps (14 instances) to prevent
    credential persistence (artipacked)
  • Fix template injection by replacing ${{ }} in run: blocks with shell env vars
    (template-injection):
    • ${{ github.base_ref }}${GITHUB_BASE_REF} (HIGH severity)
    • ${{ env.* }}${VAR_NAME} (env vars are already available as shell vars)
    • ${{ needs.*.result }} and ${{ steps.*.outputs.* }} → env vars via env: block

Commit 2: Add zizmor CI check

  • Add zizmor.yaml workflow that runs on pushes to main and all PRs
  • Uploads SARIF results to GitHub Advanced Security for stateful triage

Commit 3: Fix remaining non-secrets findings

  • Scope checks: write permission to job level instead of workflow level in ci.yaml and e2e-matrix-extras.yaml (excessive-permissions)
  • Fix template injection in github-script steps by passing values through process.env instead of ${{ }} expansion (template-injection)
  • Replace peter-evans/create-or-update-comment action with gh CLI (superfluous-actions)

Results:

  • Before: 56 findings (3 high, 29 medium, 10 low, 14 info)
  • After: 13 findings (0 high, 13 medium, 0 low, 0 info)

Remaining findings (tracked in follow-up issues):

Rule Count Severity Issue
secrets-outside-env 12 Medium #9668
secrets-inherit 1 Medium #9669

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

- Add persist-credentials: false to all actions/checkout steps
- Fix template injection by using env vars instead of ${{ }} in run blocks
- Convert ${{ env.* }} to shell env vars in run blocks

Fixes 32 auto-fixable findings from zizmor v1.23.1 static analysis.
Remaining findings (secrets-outside-env, excessive-permissions,
secrets-inherit, template-injection in github-script) require manual
review and are tracked separately.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Mar 26, 2026
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 26, 2026
@vdemeester
Copy link
Copy Markdown
Member Author

/kind cleanup

@tekton-robot tekton-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Mar 26, 2026
- Integrate zizmor static analysis as a CI check on PRs and pushes
- Upload results to GitHub Advanced Security for stateful triage

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the zizmor-fix-gha-security branch from 8ea561d to 1bf4a10 Compare March 26, 2026 09:08
@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 26, 2026
--repo "${REPO}" \
--body "Something went wrong with your \`/${COMMAND}\` command: [please check the logs](${RUN_URL})."
env:
GH_TOKEN: ${{ secrets.CHATOPS_TOKEN }}

Check warning

Code scanning / zizmor

secrets referenced without a dedicated environment Warning

secrets referenced without a dedicated environment
gh api "repos/${REPO}/issues/comments/${COMMENT_ID}/reactions" \
-f content='hooray'
env:
GH_TOKEN: ${{ secrets.CHATOPS_TOKEN }}

Check warning

Code scanning / zizmor

secrets referenced without a dedicated environment Warning

secrets referenced without a dedicated environment
Copy link
Copy Markdown
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Nice!
/approve

@tekton-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

- Scope checks: write to job level instead of workflow level
- Fix template injection in github-script by using process.env
- Replace peter-evans/create-or-update-comment with gh CLI

Resolves all high/low/info zizmor findings. Only secrets-outside-env
(medium, requires GitHub environment setup) remains.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the zizmor-fix-gha-security branch from 62eb660 to 6d8ad06 Compare March 26, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants