Skip to content

chore(ci): tighten workflow security and dedupe e2e setup - #14288

Merged
ChiragAgg5k merged 2 commits into
mainfrom
chore/ci-quick-fixes
Oct 9, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
chore/ci-quick-fixes

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

First step of the CI cleanup: quick fixes that don't change what runs on which change.

What changed

  • CodeQL actually runs. It targeted master, so only the weekly cron ever fired. It now runs on PRs and pushes to main. The language stays javascript so the existing alert category carries over.
  • One e2e image step. The Docker Hub login, app image pull and compose pull with retries were copied into five jobs. They now live in .github/actions/images, referenced with the self-repository syntax ($/, runner ≥ 2.336; gcrunner is on 2.337).
  • Permissions. ci.yml no longer grants packages: write to every job; that was left over from the GHCR image handoff. Cache cleanup drops the dead GHCR step and the deprecated gh-actions-cache extension in favour of gh cache delete --all --ref. Workflows without a permissions: block now declare minimal ones.
  • zizmor clean. Expressions in run: scripts moved into env:. Snippet QA actions are pinned by SHA. Checkouts use persist-credentials: false unless 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.
  • New Checks / Workflows job runs zizmor 1.30.1 over .github on every run. .github/zizmor.yml excludes only the gh-aw-generated issue-triage.lock.yml. actionlint was left out: it is unmaintained and rejects parallel: steps.
  • The workflow-dispatch response_format input is now a single workflow-level API_RESPONSE_FORMAT env passed into the test container as _APP_E2E_RESPONSE_FORMAT.

Worth a look

  • split.yml / split-dev.yml now request contents: write and workflows: write instead of the app's full permission set (mirror pushes include .github/workflows/mirror.yml, and releases need contents). split-dev is also limited to the named mirrors. If the split app lacks either permission, token creation fails on the first main push after merge.
  • Console deploy tokens request only contents: write.
  • specs.yml pushes to appwrite/specs with GITHUB_TOKEN, which can't write to another repository. That was already the case before this PR; flagging it here so it gets fixed separately.
  • The snippet QA workflows (dispatch-only) move from checkout v4 to v6.0.2 and haven't been run.

Closes #14289

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
@luxor-code-review

luxor-code-review Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high · 🟡 1 medium

💬 Inline comments (2)

  • 🟠 Invalid local action ref $/ breaks e2e jobs — ci.yml:579
  • 🟡 Unscoped app token gains workflows: write — split.yml:33

The change consolidates CI pipeline security across the repo: every workflow gets explicit least-privilege permissions, third-party actions are pinned to SHAs, persist-credentials: false is set on checkouts, and untrusted ${{ }} interpolations are moved into quoted env vars. A new composite image-build action is extracted and consumed from .github/workflows/ci.yml, which also switches matrix values to env-var indirection. Release/publish/split workflows are reduced to contents: read where possible, and cleanup-cache.yml is rewritten around gh cache delete --all. The hardening is largely consistent; the review found one build-breaking local-action reference and one over-scoped token to fix before merge.

Files Change
.github/workflows/ci.yml, .github/actions/images/action.yml Introduce the composite image action, env-var indirection for matrix values, and new background-pull/retry logic; also introduces the invalid $/ action ref that breaks e2e jobs.
.github/workflows/split.yml, split-dev.yml, publish.yml, release.yml, nightly.yml Re-scope app tokens and workflow permissions for mirror/publish flows, including a workflows: write grant on split.yml.
.github/workflows/cleanup-cache.yml, codeql-analysis.yml, security-scan.yml, stale.yml Rewrite cache cleanup to gh cache delete --all, adjust CodeQL build modes and branch name, and pin remaining actions.
.github/workflows/console*.yml, sdk-preview.yml, specs.yml, zizmor.yml Apply the same pinning, permissions, and interpolation-hardening pattern to console, SDK-preview, and specs pipelines; add zizmor audit config.

Reviewed commit: 5732501

@ghost

ghost commented Oct 9, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The previously reported stale-workflow permission finding remains open from the earlier review.

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 main. It also updates cache cleanup, pins or upgrades workflow actions, and narrows the permissions used by deployment and split workflows. The latest split-workflow update scopes each app token to the mirror repositories resolved for the current tag or branch push.

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.

Verdict New comments Fixed Still open
💬 Commented 0 0 1

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
File Change
.github/actions/images/action.yml Adds a reusable composite action for Docker Hub login and retrying application and Compose image pulls.
.github/workflows/ci.yml Updates CI permissions and e2e image setup, passes script expressions through environment variables, and adds zizmor auditing.
.github/workflows/cleanup-cache.yml Removes the dead GHCR cleanup step and uses the built-in GitHub cache deletion command.
.github/workflows/codeql-analysis.yml Runs CodeQL on pull requests and pushes to main as well as its scheduled scan.
.github/workflows/console-production.yml Disables persisted checkout credentials and narrows deployment app-token permissions.
.github/workflows/console-staging.yml Disables persisted checkout credentials and narrows deployment app-token permissions.
.github/workflows/console-snippets-qa-android.yml Pins workflow actions by SHA and disables persisted checkout credentials.
.github/workflows/console-snippets-qa-ios.yml Pins workflow actions by SHA and disables persisted checkout credentials.
.github/workflows/console-snippets-qa-server.yml Pins workflow actions by SHA and disables persisted checkout credentials.
.github/workflows/console-snippets-qa-web.yml Pins workflow actions by SHA and disables persisted checkout credentials.
.github/workflows/console.yml Disables persisted checkout credentials across Console jobs.
.github/workflows/nightly.yml Disables persisted checkout credentials for the resolved build.
.github/workflows/publish.yml Declares explicit workflow permissions and disables persisted checkout credentials.
.github/workflows/release.yml Declares explicit workflow permissions and disables persisted checkout credentials.
.github/workflows/sdk-preview.yml Declares explicit workflow permissions and disables persisted checkout credentials.
.github/workflows/security-scan.yml Declares explicit workflow permissions and disables persisted checkout credentials.
.github/workflows/specs.yml Declares explicit workflow permissions and disables persisted checkout credentials.
.github/workflows/split-dev.yml Limits split-dev token creation to the named mirror repositories and required permissions.
.github/workflows/split.yml Scopes split app tokens to the resolved target mirrors, with tag pushes targeting one mirror.
.github/workflows/stale.yml Declares explicit permissions for the stale-issue job.
.github/zizmor.yml Excludes the generated issue-triage workflow from selected zizmor rules.
⏳ Still open from earlier reviews · 1

Reviewed the commits since 5732501 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

stale:
runs-on: ubuntu-24.04
permissions:
actions: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leaving this as is in this PR. Some context:

  • actions/stale is GitHub's own action from the actions org, 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 shows Actions: write, Contents: write, Deployments: write and every other scope. This PR narrows it to actions, issues and pull-requests.
  • The only thing that uses actions: write is the action's own state cleanup. If we drop it, any run that stops at operations-per-run would 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/split.yml Resolved
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → chore/ci-quick-fixes (after).

Metric Before After Change
🚀 Requests/sec 192.99 201.92 ⚪ +4.6%
⏱️ Latency P50 90.28 ms 86.99 ms ⚪ -3.6%
⏱️ Latency P95 210.13 ms 193.77 ms 🟢 -7.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 86.99 193.77 12,654 201.92 -16.36
Account 161.5 307.91 666 11.06 -26.32
TablesDB 85.04 160.01 6,882 111.1 -5.55
Storage 78.95 166.62 3,330 55.91 -14.44
Functions 119.82 227.6 1,776 30.47 -29.72

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.create 463.24
functions.variables.update 455.26
tablesdb.rows.increment 395.79
account.prefs.update 390.77
account.name.update 386.52

@ChiragAgg5k
ChiragAgg5k merged commit 3e483dc into main Oct 9, 2026
336 of 339 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the chore/ci-quick-fixes branch October 9, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tighten CI workflow security and dedupe e2e setup

2 participants