Skip to content

fix(ci): isolate Node cache writes - #127107

Merged
vincentkoc merged 1 commit into
mainfrom
security/actions-cache-policy
Aug 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
security/actions-cache-policy

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves a problem where pull-request-capable workflows could execute repository-controlled setup code in jobs that also had authority to publish shared Node-oriented GitHub Actions caches. That coupling let untrusted changes influence Node toolchain, dependency, pnpm, Vitest, compile, and build cache contents.

Addresses CodeQL alerts #719-723, #785, and #795.

Scope is intentionally limited to the Node-oriented cache families named by those alerts and their direct callers. Android SDK, Cargo, and Swift caches are unchanged and outside this lane.

Why This Change Was Made

The shared Node and pnpm setup actions now expose one explicit cache-mode: off|restore|read-write contract that defaults to off, validate it, and remain restore-only. Every caller declares its authority, PR-capable Node cache paths use restore-only actions, and every remaining save step requires validated read-write authority.

This removes the legacy per-cache save switches and the CI matrix's in-run Vitest writer election. The protected warmer publishes shared CI caches; trusted release, Testbox, and proof workflows retain their existing cache saves through the same contract. Publication behavior is unchanged.

User Impact

CI retains cache restoration, but pull requests can no longer publish Node toolchain, dependency, pnpm, Vitest, compile, or build caches. Trusted cache publication is explicit and structurally enforced.

Evidence

  • Exact head: d34ddc0687bbb22662133ef6a848a7cdeeee2950
  • Caller inventory: 124 setup-action calls, 0 implicit modes: 110 restore, 9 off, 3 trusted read-write, 1 dispatch-only read-write|restore, and 1 conditional restore|off.
  • Direct cache inventory: 10 save steps, all gated on validated cache-mode == 'read-write'; no save-capable Node cache action remains in pull-request execution.
  • Structural guard proves both setup actions default off, contain restore-only cache actions, reject invalid modes, have no legacy save inputs, forbid direct save-capable Node cache paths, and gate every direct save.
  • Focused Vitest:
    • cache-policy/workflow guards: 4 passed
    • package-acceptance callers: 3 passed
    • CI cache-warm planner: 23 passed
    • plugin-prerelease caller: 1 passed
    • trusted release/proof saves: 2 passed
  • pnpm deadcode:dependencies passed.
  • node scripts/check-changed.mjs -- <affected paths> passed all selected tooling, scripts, test-root typecheck, formatting, and lint lanes.
  • git diff --check, targeted oxfmt --check, YAML parse, composite-action schema probe, and privacy scrub passed.
  • Production delta: +337/-231, net +106. The positive delta is the explicit security authority boundary and save-key handoff for the affected cache families. Tests: +276/-162, net +114.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc requested review from a team August 21, 2026 08:22
@vincentkoc vincentkoc self-assigned this Aug 21, 2026
@vincentkoc
vincentkoc force-pushed the security/actions-cache-policy branch from 215c8e8 to 04d0699 Compare August 21, 2026 08:22
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L maintainer Maintainer-authored PR labels Aug 21, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head: 04d069923f5ab92567c5b47fe55a53231f5dcafb

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc marked this pull request as ready for review August 21, 2026 08:25
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 21, 2026, 5:36 AM ET / 09:36 UTC.

ClawSweeper review

What this changes

This PR replaces implicit Node and pnpm cache saves with explicit off, restore, or read-write modes and moves their publishing into selected trusted workflows.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open. The prior Node/dist writer finding is addressed, but the new guard still permits bare cache writers in pull-request workflows, so the stated cache-write isolation remains incomplete.

Priority: P1
Reviewed head: d34ddc0687bbb22662133ef6a848a7cdeeee2950
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The Node-cache repair is substantial, but the remaining direct writer paths leave a merge-blocking security-boundary gap.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored CI workflow PR is assessed through source, workflow guards, and exact-head CI rather than the external-contributor proof gate.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored CI workflow PR is assessed through source, workflow guards, and exact-head CI rather than the external-contributor proof gate.
Evidence reviewed 5 items Previous Node-cache finding addressed: The PR’s pull-request-capable artifact workflow selects restore mode and gates its dist cache save on read-write mode, addressing the earlier direct Node/dist writer path.
Remaining pull-request cache writer: The Linux workflow runs on pull_request and still uses the bare actions/cache action for Cargo registry, Git, and target outputs; the branch’s own guard distinguishes this variant from restore-only usage.
Guard excludes non-Node cache writers: The new structural guard only rejects bare actions/cache when the path matches a Node-focused pattern, allowing the Linux Cargo and CI Swift cache writers to remain outside the authority contract.
Findings 1 actionable finding [P1] Cover every PR-capable Actions cache writer
Security Needs attention Direct PR cache writers bypass the authority contract: The Linux pull-request workflow still uses a bare cache action for Cargo outputs, while the new test only excludes bare actions for Node-oriented paths.

Live Verification

Command: node scripts/run-vitest.mjs test/scripts/ci-workflow-guards.test.ts

Result: PASS (completed)

     ✓ keeps workflow guards in fast CI-routing checks  470ms
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-AWRP6x/origin.git
 * [new branch]      main -› main
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppress this warning,
hint: call:
hint:
hint:   git config --global init.defaultBranch ‹name›
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m ‹name›
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-P8wi46/origin.git
 * [new branch]      main -› main
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppress this warning,
hint: call:
hint:
hint:   git config --global init.defaultBranch ‹name›
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m ‹name›
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-rnHcpa/origin.git
 * [new branch]      main -› main
Switched to a new branch 'automation/locale'
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-rnHcpa/origin.git
 * [new branch]      automation/locale -› automation/locale
Switched to branch 'main'
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppress this warning,
hint: call:
hint:
hint:   git config --global init.defaultBranch ‹name›
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m ‹name›
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-eoSJw7/origin.git
 * [new branch]      main -› main
Switched to a new branch 'automation/locale'
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-eoSJw7/origin.git
 * [new branch]      automation/locale -› automation/locale
Switched to branch 'main'
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppress this warning,
hint: call:
hint:
hint:   git config --global init.defaultBranch ‹name›
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m ‹name›
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-k3MBWj/origin.git
 * [new branch]      main -› main
Switched to a new branch 'automation/locale'
To /tmp/clawsweeper-live-proof-127107-G6hT83/profile/tmp/openclaw-generated-pr-k3MBWj/origin.git
 * [new branch]      automation/locale -› automation/locale
Switched to branch 'main'
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppres
… output truncated …

Assertions:

  • PASS expect_output: Test Files

How this fits together

GitHub Actions workflows use shared Node and pnpm setup actions before builds and tests. The setup actions restore caches, while trusted workflows explicitly publish cache entries for later runs.

flowchart LR
  A[Workflow trigger] --> B[Shared setup action]
  B --> C[Cache mode validation]
  C --> D[Restore-only cache]
  C --> E[Trusted cache writer]
  D --> F[Build and tests]
  E --> G[Shared cache]
Loading

Decision needed

Question Recommendation
Should this cache-isolation change cover all pull-request-capable Actions cache writers, including Cargo and Swift caches, as its title and stated authority boundary imply? Cover every PR-capable writer: Convert or relocate the remaining Cargo and Swift cache saves and extend the guard to enumerate the resulting trusted writers.

Why: The current branch deliberately limits its structural check to Node-oriented paths, while remaining bare cache writers execute in pull-request workflows; choosing a narrower permanent boundary is a maintainer security-policy decision.

Before merge

  • Cover every PR-capable Actions cache writer (P1) - The new guard accepts bare actions/cache@ steps whenever their path is not Node-shaped. That leaves the Cargo writers in .github/workflows/linux-app.yml and Swift writers in .github/workflows/ci.yml outside the new authority contract even though those workflows run pull-request code. Make them restore-only or route their saves through trusted writers, then guard that complete inventory.
  • Resolve security concern: Direct PR cache writers bypass the authority contract - The Linux pull-request workflow still uses a bare cache action for Cargo outputs, while the new test only excludes bare actions for Node-oriented paths.
  • Resolve merge risk (P1) - Bare actions/cache writers remain in pull-request-capable Linux and macOS CI paths, so repository-controlled build output can still reach cache publication outside the new authority contract.
  • Resolve merge risk (P1) - The PR adds a net +106 production workflow/tooling lines; that growth is justified only if the final boundary covers every relevant direct writer rather than Node paths alone.

Findings

  • [P1] Cover every PR-capable Actions cache writer — test/scripts/ci-workflow-guards.test.ts:3540-3543
  • [high] Direct PR cache writers bypass the authority contract — .github/workflows/linux-app.yml:56
Agent review details

Security

Needs attention: The new cache authority model leaves direct pull-request cache writers outside its protection.

PR surface

Tests +114, Config +127, Other -21. Total +220 across 59 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 6 276 162 +114
Docs 0 0 0 0
Config 52 336 209 +127
Generated 0 0 0 0
Other 1 1 22 -21
Total 59 613 393 +220

Review metrics

Metric Value Why it matters
Cache authority defaults 2 shared setup actions changed to default off Callers must now declare restore or write authority instead of inheriting cache access.
Production versus test LOC production +337/-231 (net +106); tests +273/-160 (net +113) The growth is justified by a security boundary only if it closes all relevant writer paths.

Stored data model

Persistent data-model change detected: persistent cache schema: .github/actions/setup-node-env/action.yml, persistent cache schema: .github/actions/setup-pnpm-store-cache/action.yml, persistent cache schema: .github/actions/setup-release-harness/action.yml, persistent cache schema: .github/workflows/android-release.yml, persistent cache schema: .github/workflows/ci-build-artifacts-testbox.yml, persistent cache schema: .github/workflows/ci-check-arm-testbox.yml, and 53 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete the writer boundary (recommended)
    Make every pull-request-capable direct cache action restore-only or route its save through a trusted workflow, then expand the guard accordingly.
  2. Constrain the PR to Node caches
    Accept that Cargo and Swift caches remain outside this boundary only after narrowing the PR’s claims and documenting that security scope.

Technical review

Best possible solution:

Convert every pull-request-capable direct cache action to restore-only or move its save into a trusted writer, then make the structural guard enumerate all permitted writers rather than filtering by Node path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: an apps/linux pull request triggers the Linux workflow, which runs a bare cache action before Cargo builds and tests; the new guard explicitly leaves that non-Node writer outside its check.

Is this the best way to solve the issue?

No. Explicit modes are a good owner boundary for Node caches, but the new guard proves only a Node-path subset while direct pull-request cache writers remain.

Full review comments:

  • [P1] Cover every PR-capable Actions cache writer — test/scripts/ci-workflow-guards.test.ts:3540-3543
    The new guard accepts bare actions/cache@ steps whenever their path is not Node-shaped. That leaves the Cargo writers in .github/workflows/linux-app.yml and Swift writers in .github/workflows/ci.yml outside the new authority contract even though those workflows run pull-request code. Make them restore-only or route their saves through trusted writers, then guard that complete inventory.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f7cbe9e5daec.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: This security hardening remains incomplete for pull-request CI cache writers.
  • merge-risk: 🚨 automation: The PR changes cache behavior in shared Actions workflows.
  • merge-risk: 🚨 security-boundary: Remaining bare cache actions bypass the new explicit write-authority contract.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp. Replaced prior rating: 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored CI workflow PR is assessed through source, workflow guards, and exact-head CI rather than the external-contributor proof gate.

Evidence

Security concerns:

  • [high] Direct PR cache writers bypass the authority contract — .github/workflows/linux-app.yml:56
    The Linux pull-request workflow still uses a bare cache action for Cargo outputs, while the new test only excludes bare actions for Node-oriented paths.
    Confidence: 0.9

What I checked:

Likely related people:

  • vincentkoc: Authored the current cache-mode contract and its workflow guard. (role: current cache-authority contributor; confidence: high; commits: d34ddc0687bb; files: .github/actions/setup-node-env/action.yml, test/scripts/ci-workflow-guards.test.ts)
  • steipete: Recent history contains repeated CI cache and runner-routing changes, including the direct cache writer context. (role: recent CI and cache-area contributor; confidence: medium; commits: c06f993b5cb3, 1400049ae9cf; files: .github/workflows/ci.yml, .github/workflows/linux-app.yml)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Convert or relocate every PR-capable direct cache writer and expand the structural guard to cover the final inventory.
  • After the correction, provide an exact-head workflow-guard result with sensitive details redacted.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-21T08:32:34.033Z sha 04d069923f5ab92567c5b47fe55a53231f5dcafb :: found issues before merge. :: [P1] Remove direct cache writers from PR CI | [P3] Remove the release-owned changelog entry

@vincentkoc
vincentkoc force-pushed the security/actions-cache-policy branch from 04d0699 to 5d887b2 Compare August 21, 2026 09:03
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the security/actions-cache-policy branch from 5d887b2 to 64b3b9b Compare August 21, 2026 09:16
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the security/actions-cache-policy branch from 64b3b9b to d34ddc0 Compare August 21, 2026 09:29
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc vincentkoc changed the title fix(ci): isolate Actions cache writes fix(ci): isolate Node cache writes Aug 21, 2026
@vincentkoc
vincentkoc merged commit 225aa5a into main Aug 21, 2026
178 of 179 checks passed
@vincentkoc
vincentkoc deleted the security/actions-cache-policy branch August 21, 2026 09:45
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant