Skip to content

fix(ci): prevent manual candidates from writing shared caches - #127149

Merged
vincentkoc merged 1 commit into
mainfrom
security/ci-candidate-cache-trust
Aug 21, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
security/ci-candidate-cache-trust

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes a CI security issue where an arbitrary workflow_dispatch.target_ref could run candidate-controlled steps before shared cache writers completed, allowing an untrusted manual target to influence caches used by later trusted runs.

CodeQL scope:

Why This Change Was Made

CI preflight now owns one canonical candidate trust decision and exports candidate_trust, cache_mode, and cache_write_allowed. Trust defaults to untrusted with caches off; pull requests restore only; exact main and validated release identities may write. Release context authorization additionally proves the target SHA is the named release branch head or an ancestor of it.

Workflow-owned local actions are loaded from an exact github.workflow_sha harness, separately from candidate code. Every direct cache surface now consumes the canonical mode or write authorization, including dependency warmup, build/dist, Playwright, extension artifacts, Vitest/Node, Go, Swift, Android SDK, Gradle, Windows, and macOS. Implicit read-write Go/Java caches were replaced with restore/save-aware flows; Gradle uses the maintained gradle/actions/setup-gradle basic provider in native read-only mode for non-writers.

The architectural owner is CI preflight. Candidate identity is established once there; cache consumers no longer re-derive trust from event shape.

User Impact

No product-facing behavior changes. Maintainers retain pull-request restores and exact main/release cache publication, while arbitrary manual targets can still run tests without reading or writing shared caches.

Evidence

Exact head: 63c4cf5d4ca2d46c6e208777baec3137118600be

  • node scripts/run-vitest.mjs test/scripts/ci-workflow-guards.test.ts: 124 passed, 2 skipped
  • node scripts/run-vitest.mjs test/scripts/pr-ci-dispatch.test.ts test/scripts/pr-prepare-gates.test.ts test/scripts/full-release-validation-at-sha.test.ts: 67 passed
  • actionlint -shellcheck '' -pyflakes '' .github/workflows/ci.yml .github/workflows/android-release.yml: passed
  • pre-commit run zizmor --files .github/workflows/ci.yml .github/workflows/android-release.yml: passed
  • YAML parse and git diff --check: passed
  • changed-file policy, formatting, dependency-pin, patch, conflict-marker, and declaration guards: passed
  • local test-root typecheck reached one environment-only failure: the shared linked node_modules contains [email protected] while this checkout requires [email protected]; no dependency install was run inside the Codex worktree. Hosted CI remains authoritative for that lane.

Privacy scrub: no personal paths, private hosts/IPs, phone numbers, or non-public email addresses in the diff.

LOC proof:

  • CI production/config: +279/-85
  • tests: +381/-42

Positive production growth is justified by the cache-write security invariant and its explicit owner/lifecycle boundaries. No changelog entry: this is internal CI hardening with no shipped user-facing surface.

@vincentkoc vincentkoc added security Security documentation maintainer Maintainer-authored PR github_actions Pull requests that update GitHub Actions code labels Aug 21, 2026
@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 self-assigned this Aug 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed security Security documentation labels Aug 21, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 21, 2026 10:30
@vincentkoc
vincentkoc requested a review from a team August 21, 2026 10:30
@vincentkoc
vincentkoc force-pushed the security/ci-candidate-cache-trust branch from 4852174 to 63c4cf5 Compare August 21, 2026 10:35
@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:

@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. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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: needs maintainer review before merge. Reviewed August 21, 2026, 6:41 AM ET / 10:41 UTC.

ClawSweeper review

What this changes

Centralizes CI candidate trust in preflight and uses it to prevent manually selected revisions from restoring or writing shared caches unless their identity is trusted.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for protected maintainer review: the preflight-owned policy is coherent and guard-covered, but the new Gradle action’s read-only cache contract could not be directly inspected. Likely related people: Vincent Koc (current CI change) and Peter Steinberger (Android toolchain history).

Priority: P2
Reviewed head: 63c4cf5d4ca2d46c6e208777baec3137118600be
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The policy shape and guard coverage are strong, with one third-party cache-contract verification still required before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored CI hardening PR is assessed through workflow guards and exact-head CI rather than the external-contributor proof gate.
Patch quality 🐚 platinum hermit (4/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored CI hardening PR is assessed through workflow guards and exact-head CI rather than the external-contributor proof gate.
Evidence reviewed 5 items Current-main exposure: Current main’s Android toolchain uses combined cache actions without a caller-provided cache authority; the PR replaces this with explicit off, restore, and read-write modes.
Canonical policy owner: Preflight defaults to untrusted/off and enables cache writes only for main or validated release identities.
Sibling cache paths: Direct Go and Swift cache saves consume preflight write authority, while local workflow actions load from the workflow revision rather than candidate code.
Findings None None.
Security Needs attention Verify the Gradle action’s read-only cache contract: Manual-candidate isolation relies on cache-read-only in a newly added third-party action whose exact source was unavailable for direct inspection.

How this fits together

CI preflight resolves a requested revision and determines its trust before build and test jobs run. That decision controls downstream access to shared dependency, platform, and build caches.

flowchart LR
A[CI trigger] --> B[Preflight revision validation]
B --> C[Candidate trust decision]
C --> D[Cache access mode]
D --> E[Build and test jobs]
E --> F[Shared caches]
Loading

Decision needed

Question Recommendation
Does the pinned Gradle action guarantee that cache-read-only blocks every shared-cache write from this Android setup action? Verify the pinned action: Inspect the exact action source and retain this integration if its read-only mode prevents cache publication.

Why: The PR’s Android isolation depends on a newly introduced third-party action contract that was unavailable for direct inspection.

Before merge

  • Resolve security concern: Verify the Gradle action’s read-only cache contract - Manual-candidate isolation relies on cache-read-only in a newly added third-party action whose exact source was unavailable for direct inspection.
  • Resolve merge risk (P1) - The Android Gradle path relies on an uninspected third-party cache-read-only contract; it needs direct source or behavioral proof before merge.
  • Complete next step (P2) - Protected maintainer handling is needed to verify the external cache contract and review the completed exact-head CI.

Findings

  • [medium] Verify the Gradle action’s read-only cache contract — .github/actions/setup-android-toolchain/action.yml:40
Agent review details

Security

Needs attention: The new Gradle cache integration needs exact-source or behavioral verification of its no-write mode before the security boundary can be cleared.

PR surface

Tests +338, Config +195. Total +533 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 380 42 +338
Docs 0 0 0 0
Config 3 280 85 +195
Generated 0 0 0 0
Other 0 0 0 0
Total 4 660 127 +533

Review metrics

Metric Value Why it matters
Production versus test LOC production +280/-85; tests +380/-42 The workflow growth implements a cross-job cache-authorization boundary and is paired with focused CI guard coverage.

Stored data model

Persistent data-model change detected: persistent cache schema: .github/actions/setup-android-toolchain/action.yml, persistent cache schema: .github/workflows/android-release.yml, persistent cache schema: test/scripts/ci-workflow-guards.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove Gradle no-write behavior (recommended)
    Verify the pinned action’s read-only implementation or add behavioral evidence that manual candidates cannot publish Gradle caches.
  2. Pause the Gradle integration
    Retain the explicit cache hardening but remove the new Gradle action until its no-write contract is verified.

Technical review

Best possible solution:

Keep one preflight-owned cache-authority flow, verify the pinned Gradle action prevents publication in non-writer modes, then merge after exact-head CI is green.

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

Yes at the source boundary: the guard suite executes the target-context and candidate-trust shell paths with controlled inputs. A hosted cache-service trace was not available in this read-only review.

Is this the best way to solve the issue?

Unclear: making preflight the sole authority is the cleanest owner boundary found, but the Gradle action contract must be verified before this exact implementation is accepted.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded CI cache-integrity hardening change without an observed product-runtime outage.
  • add merge-risk: 🚨 security-boundary: An incorrect cache-mode interpretation could let candidate-controlled Android work publish data reused by trusted runs.
  • add merge-risk: 🚨 automation: The patch changes central GitHub Actions preflight and shared-cache behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored CI hardening PR is assessed through workflow guards and exact-head CI rather than the external-contributor proof gate.

Label justifications:

  • P2: This is a bounded CI cache-integrity hardening change without an observed product-runtime outage.
  • merge-risk: 🚨 security-boundary: An incorrect cache-mode interpretation could let candidate-controlled Android work publish data reused by trusted runs.
  • merge-risk: 🚨 automation: The patch changes central GitHub Actions preflight and shared-cache behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored CI hardening PR is assessed through workflow guards and exact-head CI rather than the external-contributor proof gate.

Evidence

Security concerns:

  • [medium] Verify the Gradle action’s read-only cache contract — .github/actions/setup-android-toolchain/action.yml:40
    Manual-candidate isolation relies on cache-read-only in a newly added third-party action whose exact source was unavailable for direct inspection.
    Confidence: 0.9

What I checked:

Likely related people:

  • Vincent Koc: Blame attributes the new preflight cache-authority decision to the reviewed commit. (role: current implementation author and CI area contributor; confidence: high; commits: 63c4cf5d4ca2; files: .github/workflows/ci.yml, .github/actions/setup-android-toolchain/action.yml)
  • Peter Steinberger: History attributes the shared Android toolchain and its subsequent maintenance to this area contributor. (role: Android toolchain feature owner; confidence: high; commits: b6b8e59b9e55, d739daef1081; files: .github/actions/setup-android-toolchain/action.yml)

Rank-up moves

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

  • Verify the pinned Gradle action’s cache-read-only behavior.
  • Wait for exact-head required CI to complete successfully.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

Addressing the ClawSweeper rank-up move and security concern with direct source proof from the exact pinned gradle/actions commit 9c971963bec38e04b3d30dcc455b5382be2fdbfb:

Conclusion: cache-read-only: true on the explicitly selected basic provider cannot publish a Gradle cache. The exact-head CodeQL Actions, Workflow Sanity, PR-context evidence, and focused local guard suites are also green. No head change was needed.

@vincentkoc
vincentkoc merged commit 67630f6 into main Aug 21, 2026
178 of 179 checks passed
@vincentkoc
vincentkoc deleted the security/ci-candidate-cache-trust branch August 21, 2026 10:47
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code 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. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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