Skip to content

fix: harden action inputs and downloads, document all inputs - #79

Merged
cpanato merged 6 commits into
mainfrom
harden-inputs-and-readme
Nov 3, 2026
Merged

cpanato merged 6 commits into
mainfrom
harden-inputs-and-readme

Conversation

@cpanato

@cpanato cpanato commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Xref: https://linear.app/chainguard/issue/ACID-1907/new-setup-chainctl-release-supports-selecting-a-specific-version

Security fixes and improvements for the action, plus a README that covers every input.

Fixes

  • More inputs are validated up front. environment and version go into the download URL, and the checksum comes from that same URL. A crafted value (e.g. environment: evil.example/x?) could point both at another host and still pass the check. verbosity must be 0-5. identity can't contain whitespace or control characters, since it's echoed into ::group:: log commands.
  • HTTPS only: curl uses --proto '=https' --proto-redir '=https' --tlsv1.2, so a redirect can't drop to plain HTTP.
  • Deprecated invite-code path: the OIDC token fetched by hand is now masked. The audience is URL-encoded, HTTP errors fail the step, and a missing id-token: write permission gives a clear error.
  • auth.yaml: removed allow-unsafe-pr-checkout: true. In checkout v7.0.1 the fork-PR guard is skipped for the default checkout (no ref:), so the flag did nothing today. Its only effect was to leave the guard off if a PR ref is added to this pull_request_target job, which has id-token: write.

Improvements

  • The keyring package is installed from its published wheel only (--only-binary), so no sdist build code runs.
  • Every uses: ./ is now uses: $/ (zizmor self-repository). $/ loads the action from the running commit, so the checkout steps that only existed for ./ are removed, including the one in the pull_request_target job. actionlint 1.7.12 does not support $/ yet (Support the new $/ self-repository uses: syntax rhysd/actionlint#711), so that single error is ignored.
  • Windows CI workaround for harden-runner v2.22.3 (bumped on main in Bump the actions group across 1 directory with 2 updates #78, which brought egress blocking to Windows). Its step returns several seconds before the agent is enforcing, and the agent points DNS at its proxy before the proxy can resolve anything. Without the checkout step, the chainctl download started inside that gap and failed every time, and the fast PowerShell hash job could get stuck after all steps passed (main's run hit this too). The new test-only action .github/actions/wait-for-harden-runner waits on Windows until a lookup sent straight to the proxy succeeds, then clears the DNS cache. It does nothing on Linux/macOS. Remove it once harden-runner waits for its agent.
  • Tests check that bad environment, version and verbosity values fail the action.
  • README: a table of all inputs, the required permissions, example setups, a Security section, and advice to pin the action to a commit SHA.

Testing

  • Reran the Test workflow 3 times on the final commit: every job passed, nothing hung, and the Windows download had no DNS errors. In every Windows job the wait finished after the agent logged "DNS proxy ready".
  • actionlint passes. zizmor --persona pedantic shows no new kinds of finding.
  • Ran the validation script locally: valid values pass, and path traversal, a bad domain, out-of-range verbosity and newline injection are all rejected.
  • Fetched dl.enforce.dev checksums with the new curl flags.

Follow-ups (not in this PR)

  • Verify a signature (e.g. cosign) as well as the checksum, if chainctl releases publish one.
  • Move auth.yaml from pull_request_target to pull_request with a same-repo guard, so PRs actually test their own code. This changes the OIDC claims, so the Chainguard identity binding needs checking first.

🤖 Generated with Claude Code

Comment thread .github/workflows/test.yaml Fixed
Comment thread .github/workflows/test.yaml Fixed
Comment thread .github/workflows/test.yaml Fixed
@cpanato
cpanato requested a review from jmeridth November 3, 2026 14:42
cpanato and others added 2 commits November 3, 2026 15:44
- Validate environment, version, verbosity and identity up front. The
  environment and version feed the download URL, and the checksum comes
  from the same URL, so a crafted value could redirect both.
- Restrict curl to HTTPS (including redirects) and TLS 1.2+.
- invite-code path: mask the hand-fetched OIDC token, URL-encode the
  audience, fail on HTTP errors and a missing id-token permission.
- Install the keyring package from its wheel only.
- auth.yaml: drop allow-unsafe-pr-checkout; it is a no-op for the
  default checkout and only disables the guard if a PR ref is added.
- Add rejection tests for the new validation.
- README: document every input, required permissions, scenarios and
  security behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switch every `uses: ./` to `uses: $/`, as flagged by zizmor's
self-repository audit. `$/` resolves to the exact commit that is
running instead of whatever is on disk, so the checkout steps that only
existed to support `./` are removed. That also takes actions/checkout
out of the pull_request_target job in auth.yaml.

actionlint 1.7.12 rejects `$/` (rhysd/actionlint#711), so ignore only
that error until it ships support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
@cpanato
cpanato force-pushed the harden-inputs-and-readme branch from 9662306 to 78d0483 Compare November 3, 2026 14:47
cpanato and others added 4 commits November 3, 2026 16:05
harden-runner v2.22.3 enforces egress on Windows, but its step returns
about 4s before the agent redirects DNS and turns on the block-all
filter. With the checkout step gone, the chainctl download now starts
inside that gap: it resolves outside the proxy, gets no allow rule and
is cut off, and retries reuse the cached DNS answer and stay blocked.

Wait on Windows until DNS points at the agent's proxy, then clear the
DNS cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
The hash job finishes about 4s after harden-runner returns, so the Post
step stops the Windows agent before it finishes starting. That can leave
its egress filter on and the job never reports completion. Add the same
wait used in the Basic Test job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
The Windows agent points system DNS at 127.0.0.1 about a second before
its proxy has upstream servers. Lookups in that gap fail and Windows
caches the failure, which still produced the occasional "Could not
resolve host" and left the hash job unable to report completion.

Move the wait into a shared local action that waits until a lookup
through the proxy succeeds, then clears the DNS cache to drop failures
cached during the gap. Widen the actionlint ignore so it covers `$/`
paths, not just the bare root reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
The agent repoints adapters one at a time, so a normal lookup could
succeed through an adapter still on the upstream resolver while the
proxy itself had no upstreams yet. The wait then returned about 1.5s
early and the download still hit "Could not resolve host". Send the
probe straight to 127.0.0.1 so it only succeeds once the proxy works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
@cpanato
cpanato merged commit bfe7503 into main Nov 3, 2026
27 checks passed
@cpanato
cpanato deleted the harden-inputs-and-readme branch November 3, 2026 16:32
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.

3 participants