Skip to content

ci: harden docker-publish.yml (untrusted-checkout guard + zizmor findings)#8

Merged
dotCooCoo merged 2 commits into
mainfrom
fix/codeql-untrusted-checkout
Jun 14, 2026
Merged

ci: harden docker-publish.yml (untrusted-checkout guard + zizmor findings)#8
dotCooCoo merged 2 commits into
mainfrom
fix/codeql-untrusted-checkout

Conversation

@dotCooCoo

Copy link
Copy Markdown
Owner

Resolves the 3 open CodeQL actions/untrusted-checkout alerts (2 critical + 1 high), all in .github/workflows/docker-publish.yml.

Problem

The Docker publish pipeline triggers on workflow_run with packages: write + id-token: write, and its three jobs each actions/checkout ref: github.event.workflow_run.head_sha and then execute that code (npm install, docker build, smoke test). CodeQL flags this as checkout-and-execute of potentially-untrusted code in a privileged context.

Fix

Add a head-repository trust guard to each privileged job:

github.event_name != 'workflow_run' || github.event.workflow_run.head_repository.full_name == github.repository

Release only fires on upstream tag pushes, so the triggering run's head_repository is always this repository for a real release — the guard is always satisfied for legitimate publishes and blocks any fork-originated trigger from having its code checked out and run with publish/signing privileges. workflow_dispatch (manual, write-access only) is unaffected.

@github-actions

Copy link
Copy Markdown
Check Status
ESLint (JS + security)
Codebase-patterns (static-shape gates)
Changelog drift gate
Hadolint (Dockerfile)
ShellCheck (shell scripts)

…checkout

The Docker publish pipeline runs on workflow_run with packages:write +
id-token:write and checks out github.event.workflow_run.head_sha in three
jobs (lint, build-and-push, smoke-test), then executes it (npm install,
docker build, smoke). Add a head-repository trust guard to each privileged
job so it only proceeds when the triggering Release run came from this
repository, closing CodeQL's actions/untrusted-checkout (2 critical + 1
high). Release only fires on upstream tag pushes, so the guard is always
satisfied for a real release and never blocks a legitimate publish.
@dotCooCoo dotCooCoo force-pushed the fix/codeql-untrusted-checkout branch from 33b3e39 to 89ada3d Compare June 14, 2026 04:19
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown

🎉 Linting finished with no errors or warnings 🎉

Check Status
ESLint (JS + security)
Codebase-patterns (static-shape gates)
Changelog drift gate
Hadolint (Dockerfile)
ShellCheck (shell scripts)

- Scope packages:write + id-token:write to the publishing jobs (build-and-push
  pushes + cosign-signs; smoke-test pulls) instead of workflow-wide; lint runs
  read-only.
- Env-indirect the workflow_dispatch version input (template-injection).
- persist-credentials: false on all checkouts (none git-push).
- Justified ignores for the required+guarded workflow_run trigger
  (dangerous-triggers) and the no-cache setup-node (cache-poisoning).
@dotCooCoo dotCooCoo changed the title ci: guard docker-publish workflow_run against untrusted checkout (CodeQL) ci: harden docker-publish.yml (untrusted-checkout guard + zizmor findings) Jun 14, 2026
@dotCooCoo dotCooCoo merged commit de175b1 into main Jun 14, 2026
4 checks passed
@dotCooCoo dotCooCoo deleted the fix/codeql-untrusted-checkout branch June 14, 2026 13:33
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.

1 participant