Repository navigation
chore(ci): tighten workflow security and dedupe e2e setup - #14288
Conversation
CodeQL only ever ran from its weekly cron because it targeted master. The e2e image pull was copied into five jobs, CI granted packages: write to every job for a GHCR handoff that no longer exists, and zizmor flagged template injection, unpinned actions, persisted checkout credentials, over-scoped app tokens and a vulnerable setup-php pin. - Point CodeQL at main and drop the template boilerplate - Extract the Docker Hub login and image pulls into a composite action - Drop packages: write and the dead GHCR cleanup; use gh cache delete - Move expressions out of run scripts into env across workflows - Pin every action by SHA, persist-credentials: false where nothing pushes - Scope GitHub App tokens to the permissions each job uses - Bump setup-php to 2.37.2 (GHSA-pqwm-q9pv-ph8r, GHSA-5wxr-w449-57cm) - Add a Checks / Workflows job running zizmor over .github
|
Review complete. 🟠 1 high · 🟡 1 medium 💬 Inline comments (2)
The change consolidates CI pipeline security across the repo: every workflow gets explicit least-privilege
Reviewed commit: 5732501 |
🔵 Tier A · Mergeable after minor fixes
The pull request tightens GitHub Actions permissions and credential handling, centralizes the e2e image setup, and adds workflow security scanning while enabling CodeQL on pull requests and pushes to Latest changes: The newest commit resolves mirror repository names before creating the split app token, targeting one mirror for a tag and all package mirrors for a branch push.
Note Not approving while a bug finding is open: Remove the stale job's actions write permission Fix with agent prompt### Issue 1
.github/workflows/stale.yml:11
**Remove the stale job's actions write permission**
The `actions/stale` step only updates issues and pull requests, so it does not need `actions: write`. This also gives its `GITHUB_TOKEN` the ability to manage workflow runs and caches, unnecessarily widening the impact of a compromised action.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 21
⏳ Still open from earlier reviews · 1
Reviewed the commits since |
| stale: | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| actions: write |
There was a problem hiding this comment.
Remove the stale job's actions write permission
The actions/stale step only updates issues and pull requests, so it does not need actions: write. This also gives its GITHUB_TOKEN the ability to manage workflow runs and caches, unnecessarily widening the impact of a compromised action.
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/stale.yml
Line: 11
Comment:
**Remove the stale job's actions write permission**
The `actions/stale` step only updates issues and pull requests, so it does not need `actions: write`. This also gives its `GITHUB_TOKEN` the ability to manage workflow runs and caches, unnecessarily widening the impact of a compromised action.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · security · Reply if this doesn't apply.
There was a problem hiding this comment.
Keeping actions: write. actions/stale saves its progress between runs in an Actions cache and deletes the previous cache entry, which needs actions: write. The action README lists it under Recommended permissions for this reason. The job also gets issues: write and pull-requests: write, and nothing else.
There was a problem hiding this comment.
The cache explains why actions/stale recommends actions: write, but it doesn’t remove the least-privilege concern: that permission is granted to the whole job, and the token is passed directly to the third-party action (workflow lines 10–18).
Please check whether the progress cache can be retained without granting the action this broader scope, or isolate cache maintenance from the issue-processing step. If neither is feasible, the permission may be unavoidable for this setup, but the README recommendation alone doesn’t establish that.
There was a problem hiding this comment.
I checked src/classes/state/state-cache-storage.ts at v10.2.0. On save, the action looks up its state cache with getActionsCacheList and removes the previous entry with deleteActionsCacheByKey, using repo-token. Only then does it call cache.saveCache. Cache keys are immutable, so if the delete is denied, the save also fails and every run restores the same old state. The action has no input that turns state off. Splitting the cache cleanup into a separate job or step doesn't help either: the delete has to happen between this step's restore and its save, and both happen inside the one action step. So actions: write can't be avoided here. To limit the risk, the job runs only on a schedule with no untrusted input, the action is pinned by SHA, and the token can't reach anything outside this repository.
There was a problem hiding this comment.
That explains why this version of actions/stale needs actions: write, and I agree that moving cache deletion to a separate step would not work. It doesn’t remove the exposure: the same repo-scoped token is passed to the third-party action that processes issues and PRs (workflow lines 10–18). Scheduling and SHA pinning reduce risk, but don’t limit what that token can do if the action is compromised.
I still recommend replacing or adapting the action so issue processing doesn’t also require actions: write—for example, by separating its state handling from issue updates. I’m leaving the finding open.
There was a problem hiding this comment.
Leaving this as is in this PR. Some context:
actions/staleis GitHub's own action from theactionsorg, the same publisher as checkout and cache, and it's pinned by SHA.- Before this PR, the job had no
permissions:block and got the repository default token. The last run's log showsActions: write,Contents: write,Deployments: writeand every other scope. This PR narrows it toactions,issuesandpull-requests. - The only thing that uses
actions: writeis the action's own state cleanup. If we drop it, any run that stops atoperations-per-runwould leave a state cache it can't delete, and every later run would resume from that frozen state.
Moving the stale job off actions/stale is a different change from this permissions cleanup, so it stays out of this PR.
There was a problem hiding this comment.
Narrowing the token from the repository defaults is a real improvement, and I accept that actions/stale needs actions: write for its current cache implementation. But the permission still applies to the whole action: the same repo-token passed to it has repository-wide Actions write access, not just permission to delete that cache entry (workflow lines 10–18).
The schedule and SHA pin reduce exposure, but not the impact if the action is compromised. Keeping this implementation may be a deliberate residual-risk decision; it doesn’t resolve the security finding. I’m leaving it open until the permission is removed or the action’s cache handling is changed.
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
There was a problem hiding this comment.
This PR hardens 21 GitHub Actions workflows and a composite image action by SHA-pinning actions, scoping permissions, disabling persisted credentials, and routing ${{ }} interpolations through env vars.
Key findings
- 🟠 Invalid local action ref
$/breaks e2e jobs — ci.yml:579 - 🟡 Unscoped app token gains
workflows: write— split.yml:33
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
First step of the CI cleanup: quick fixes that don't change what runs on which change.
What changed
master, so only the weekly cron ever fired. It now runs on PRs and pushes tomain. The language staysjavascriptso the existing alert category carries over..github/actions/images, referenced with the self-repository syntax ($/, runner ≥ 2.336; gcrunner is on 2.337).ci.ymlno longer grantspackages: writeto every job; that was left over from the GHCR image handoff. Cache cleanup drops the dead GHCR step and the deprecatedgh-actions-cacheextension in favour ofgh cache delete --all --ref. Workflows without apermissions:block now declare minimal ones.run:scripts moved intoenv:. Snippet QA actions are pinned by SHA. Checkouts usepersist-credentials: falseunless a later step pushes. App tokens request only the permissions the job uses. setup-php is bumped 2.37.0 → 2.37.2 for GHSA-pqwm-q9pv-ph8r and GHSA-5wxr-w449-57cm.Checks / Workflowsjob runs zizmor 1.30.1 over.githubon every run..github/zizmor.ymlexcludes only the gh-aw-generatedissue-triage.lock.yml. actionlint was left out: it is unmaintained and rejectsparallel:steps.response_formatinput is now a single workflow-levelAPI_RESPONSE_FORMATenv passed into the test container as_APP_E2E_RESPONSE_FORMAT.Worth a look
split.yml/split-dev.ymlnow requestcontents: writeandworkflows: writeinstead of the app's full permission set (mirror pushes include.github/workflows/mirror.yml, and releases need contents).split-devis also limited to the named mirrors. If the split app lacks either permission, token creation fails on the firstmainpush after merge.contents: write.specs.ymlpushes toappwrite/specswithGITHUB_TOKEN, which can't write to another repository. That was already the case before this PR; flagging it here so it gets fixed separately.Closes #14289