Skip to content

ci: lock the actions in actions.lock, drop the write-all defaults and scope the benchmark secrets - #1975

Open
thomasboni wants to merge 1 commit into
ClickHouse:mainfrom
thomasboni:ci-hardening
Open

thomasboni wants to merge 1 commit into
ClickHouse:mainfrom
thomasboni:ci-hardening

Conversation

@thomasboni

@thomasboni thomasboni commented Aug 11, 2026 •

Copy link
Copy Markdown

Summary

Three changes, one commit, rebased on main.

  • .github/workflows/actions.lock, GitHub's workflow dependency lockfile, generated with gh actions-lock, records the commit of every action, and the runner executes that commit whatever the tag says, so a moved tag cannot change what runs. The refs become exact releases, readable, no hash in the files. CodeQL moves from v1 to v4, the two checkout@main refs to a release.
  • run-tests.yml, run-tests-head.yml and release.yml defaulted to write-all. None writes with GITHUB_TOKEN, release.yml uses its App token for checkout, release and push. All three declare contents: read.
  • stresshouse-benchmark-compare.yml forwarded every secret with secrets: inherit. The shared workflow declares two, now passed explicitly.

Why: a moved tag on any action in release.yml runs with the App token that publishes releases, the way tj-actions/changed-files leaked secrets in March 2025 (CVE-2025-30066).

Left alone: the integrations-shared-workflows@main calls, your own, a lockfile cannot cover reusable workflows. Allowed-actions patterns like owner/action@v1 now need owner/action@*.

Found and fixed with Plumber (D 48/100 before, C 50/100 after, the rest is the pull_request_target design and the shared workflows), reviewed and submitted by me.

Checklist

Workflow files only, no test or documentation impact.

@CLAassistant

CLAassistant commented Aug 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kavirajk kavirajk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @thomasboni for the PR.

Two things

  1. Left few comments to clarify
  2. Can you sign the CLA?

profile: pr-compare
pr_number: ${{ github.event.issue.number || inputs.pr_number }}
secrets: inherit
secrets:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not inherit the secrets here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

secrets: inherit forwards every secret into the workflow, while the callee here only declares WORKFLOW_AUTH_PUBLIC_APP_ID and WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY, so everything beyond those two is exposure with no benefit.

And this particular callee lives in a different repo (ClickHouse/integrations-shared-workflows) and is referenced on @main, meaning any future change to that workflow immediately runs here with whatever secrets we hand it.

Passing them explicitly caps what a change on that side can ever reach, and doubles as documentation of what the workflow actually needs. If the shared workflow grows a new secret later, the failure is loud (a missing-secret error) instead of a silent broadening of access.

Comment thread .github/workflows/run-tests-cloud.yml Resolved
Comment thread .github/workflows/run-lint.yml Outdated

- name: golangci-lint
uses: golangci/golangci-lint-action@v9
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not super comfortable with git commit hash here. Can't we just do @v9.3.0 here? (similar in other places?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In most cases the git commit hash is the only way to be sure the action you are using is immutable. It's highly recommended when the action comes from an external source that could be compromised and run malicious code in your pipeline (which has access to secrets, code, envs, etc.). That's the route the tj-actions/changed-files compromise took.

But in this specific case with golangci/golangci-lint-action you are right to prefer @v9.3.0, because the repo uses GitHub's immutable releases. The v9.3.0 release is marked immutable, meaning the tag can never be repointed or deleted. So @v9.3.0 gives the same guarantee as the SHA, and I'm going to switch that one back. Same for codeql-action, its releases are immutable too.

The others are different:

  • lychee-action@v2.9.0: mutable tag from a third-party org. I'd keep the SHA here, but if you prefer the tag for readability I can revert it.
  • claude-code-action@v1.0.190: mutable tag, maintained by Anthropic. Larger vendor, but still a third party with a repointable tag. Your call, tell me which way you want it.
  • actions/checkout@v5.1.0: mutable tag, maintained by GitHub itself. If you trust GitHub the tag is reasonable, I will revert to @v5.1.0 (tell me if not).

Comment thread .github/workflows/run-tests-cloud.yml Resolved
Comment thread .github/workflows/run-tests-cloud.yml Resolved
@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Claude review

Re-review of the CI hardening PR. The previous round's remove-label regression is fixed, and the change is otherwise sound — one likely token-scope gap remains in the new remove-label job (see inline).

Verified this round:

  • The remove-label job condition now carries the tests:run-cloud guard, so unrelated label events no longer trigger it (prior thread resolved).
  • All re-pinned refs resolve and run: CodeQL (v4.37.6 + checkout@v5.1.0), linkChecker (lychee SHA), and lint (golangci-lint-action@v9.3.0) are green on this PR, and the claude-code-action SHA is executing this very review.
  • release.yml performs every write (checkout, push, release publish) with the minted App token, so dropping the workflow token to contents: read is safe; the two test workflows never use the token at all.
  • persist-credentials: false on the fork-code checkout is correct — nothing in the test job needs a git credential afterwards.

Key concern: issues: write alone is likely insufficient for GITHUB_TOKEN to delete a label on a pull request (GitHub routes issue-endpoint calls on PRs through the pull-requests scope), and the || true on the gh api call would hide the 403 — silently breaking the "label is always removed" behaviour this PR promises to preserve. One-line fix inline.

Blind spots:

  • Could not verify offline that the two commit SHAs match their version comments (lychee-action → v2.9.0, claude-code-action → v1.0.190); CI only proves the SHAs exist. See general finding.
  • Could not inspect integrations-shared-workflows/clickhouse-benchmark.yml to confirm it declares exactly the two forwarded secrets. A missing required secret fails visibly at startup, but an optional secret the shared workflow consumes opportunistically would now be dropped silently.

Verdict: ⚠️ Request changes

General findings

  • ⚠️ Should fix — spot-check the two SHA-to-version mappings before merge
    The two commit pins come from an automated tool, and CI only proves the SHAs exist — not that they are the advertised releases. Confirm lycheeverse/lychee-action@e7477775… is the v2.9.0 commit and anthropics/claude-code-action@5ef2e550… is v1.0.190 (the compare view https://github.com/<owner>/<repo>/compare/<tag>...<sha> showing zero commits apart is a one-click check). A comment that misstates the pinned version defeats the audit value of the pin.

Inline comments are attached to the relevant lines. This summary updates in place on re-review.

@thomasboni

Copy link
Copy Markdown
Author

Hi @kavirajk

  • CLA is signed
  • Let me know if my answers are clear :)

@thomasboni
thomasboni force-pushed the ci-hardening branch 2 times, most recently from 7a7056c to c73ff30 Compare August 17, 2026 07:18
@kavirajk kavirajk self-assigned this Aug 24, 2026
Comment thread .github/workflows/check-pr-links.yml Outdated
branches: [main]
workflow_dispatch:

permissions:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks :) ❤️


- name: Review PR with Claude (produce findings JSON)
uses: anthropics/claude-code-action@v1
uses: anthropics/claude-code-action@5ef2e550a465a721f4f45e4a7d3c340c873e1dcc # v1.0.190

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm failing to understand the exactly rationale for SHA based versioning for claude-code-action and lyche from the PR description.

Can you help me understand @thomasboni ? This is my only concern with the PR. After than we can merge

Comment thread .github/workflows/run-tests-cloud.yml Resolved
… scope the benchmark secrets

.github/workflows/actions.lock, generated with gh actions-lock, records
the commit, owner id and repository id of every action the workflows
run. The runner executes the locked commit whatever the ref says, so a
moved tag cannot change what runs, and the refs in the files stay
readable versions: each floating ref moves to the exact release it
resolves to today. This replaces the commit hashes the earlier revision
of this change wrote into the files, which were the only way to get the
same guarantee before the lockfile existed. CodeQL moves off its v1 tag,
last moved in January 2023, to the current v4 release, and the two
actions/checkout@main references move to a release.

run-tests.yml, run-tests-head.yml and release.yml defaulted to
write-all. None of them writes with GITHUB_TOKEN: the test workflows
check out and run tests, release.yml mints a GitHub App token for its
checkout, release call and push. All three declare contents: read.

stresshouse-benchmark-compare.yml forwarded every repository secret to
the shared benchmark workflow with secrets: inherit. That workflow
declares two, WORKFLOW_AUTH_PUBLIC_APP_ID and
WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY, which are now passed explicitly.
@thomasboni
thomasboni requested review from a team and polyglotAI-bot as code owners November 23, 2026 14:40
@thomasboni thomasboni changed the title ci: harden the cloud test path and pin the remaining floating actions ci: lock the actions in actions.lock, drop the write-all defaults and scope the benchmark secrets Nov 23, 2026
@thomasboni

Copy link
Copy Markdown
Author

@kavirajk sorry for the very long silence, I missed the notification on your question.

On the commit hashes: until recently, writing the commit SHA in the uses: line was the only way to make an action reference immutable. A tag like @v1 can be moved by the action's owner, or by whoever takes over that account, and the workflow then runs the new code with the job's secrets. That is how the tj-actions/changed-files compromise reached its users in March 2025 (CVE-2025-30066). The cost was readability, which you rightly pushed back on.

GitHub shipped a better mechanism in October, the workflow dependency lockfile. I rebuilt the PR on it: .github/workflows/actions.lock records the commit each action resolves to, the runner executes that commit whatever the tag says, and the refs in the files stay readable versions (claude-code-action@v1.0.286, golangci-lint-action@v9.3.0). No hash anywhere in the workflows. A bump stays a one-line change plus one gh actions-lock run.

The branch is rebased on main and squashed to one commit. Your rework of run-tests-cloud.yml is kept exactly as you landed it. The description is updated to match.

@github-actions

Copy link
Copy Markdown
Contributor

AI review gate — Waiting for AI review

  • Cursor Bugbot has not posted a review on this commit yet.

What to do:

  • Nothing to do yet if the review is running. The gate turns green when it finishes clean.
  • No review showing up? Post bugbot run as a new top-level PR comment. If that does nothing, Bugbot is probably not enabled for this repository: ask a repository administrator.
  • Finding wrong, or reviewer stuck? Ask a human with write access who is not the PR author to approve this exact commit, then re-run the gate. Their approval stands in for the AI review (a new push needs a new approval).

The gate stopped waiting after 15 minutes. The bot re-runs this gate automatically when you mark the pull request ready or the review lands; or comment /ai-gate check.
Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically.

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