Repository navigation
Conversation
…oduction Every Vercel build and every ci-turbo run gets a token that can write any entry of the team's remote cache, under a hash anyone can compute from the commit, so a branch could plant an entry that production restores: the console's bundle among them. Turn on turbo's artifact signatures (remoteCache.signature) and require keys of at least 32 bytes (futureFlags.longerSignatureKey). Production builds and ci-turbo on main sign with production's key, previews and every other ci-turbo run with the previews' key; a restore that fails to verify is a miss. ci-turbo takes its key from the GitHub environment turbo-cache-main (branch rule: main) or turbo-cache-branches, without recording a deployment, and hashes its two populations apart with CACHE_SIGNER, as VERCEL_TARGET_ENV does on Vercel. The merge queue signs as a branch until only it can create its gh-readonly-queue/ branches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🔵 Needs a closer look
The change's correctness hinges on out-of-band Vercel/GitHub secrets and environment branch rules that the diff can't confirm, and the ci-turbo workflow was never exercised during validation.
No open issues 🎉
What changed in this PR
This PR hardens the hosted cloud's Turborepo remote cache against supply-chain poisoning. Today every Vercel build of the cloud project and every ci-turbo run holds a token that can write any entry of the team's shared remote cache, and cache keys are derivable from the commit — so anyone who can push a branch could plant an entry (the console bundle, built-in schemas, generated docs sources) that a production build would restore. The change turns on Turborepo's artifact signatures so a run only restores entries signed with its own key, splitting production's key from the previews' key across both Vercel and CI, and documents the operational setup.
Changes:
turbo.json: enableremoteCache.signatureandfutureFlags.longerSignatureKey, and addCACHE_SIGNERtoglobalEnvso CI'smainand branch populations hash apart (mirroringVERCEL_TARGET_ENVon Vercel).ci-turbo.yml: select the GitHub environment (turbo-cache-mainonmain, elseturbo-cache-branches) withdeployment: false, add a post-OIDC step that copies the environment's signing-key secret intoGITHUB_ENV, and fall back to local-only cache when no token or key is present.- Docs: new "Remote cache" section in
turborepo.md, runbook env-var rows and a "Cache signatures" bullet incloud.md, and migration-plan decision 11 / "Who may write to the cache" updates.
| File | Description |
|---|---|
turbo.json |
Enables signed remote-cache entries, the 32-byte key future flag, and adds CACHE_SIGNER as a hashed global env to separate CI populations. |
.github/workflows/ci-turbo.yml |
Binds the job to a GitHub environment per ref, injects the signing key after OIDC setup, and reworks the local-cache fallback to key off the signing-key step outcome. |
docs/runbooks/cloud.md |
Adds the two TURBO_REMOTE_CACHE_SIGNATURE_KEY Vercel variables and a cache-signatures operational bullet with rotation guidance. |
docs/design/build/turborepo.md |
New "Remote cache" section: key-holder table, the gh-readonly-queue caveat, and no-key/short-key behavior. |
docs/design/build/turborepo-migration.md |
Records signatures as decision 11 and updates the "Who may write to the cache" rationale. |
Notes for the human reviewer: correctness here depends on infrastructure that isn't visible in the diff — the two Vercel variables, the two new GitHub environments, and turbo-cache-main's main-only branch rule must exist (and be created in the documented order) before/at merge, and the PR notes that ci-turbo itself and a real Vercel build were not exercised in validation. These are operational considerations rather than code defects.
Review effort: Balanced
Summary
Why: this is about turbo's build logic, which the hosted cloud's Vercel builds use and which may replace moon one day. Any build that can write turbo's shared cache could plant an entry that production then builds from; with signed entries, production takes only what production's own key signed.
Every Vercel build of the
cloudproject and everyci-turborun gets a token that can write any entry of the team's remote cache, and an entry's key follows from the commit (VERCEL_TARGET_ENVis hashed wherever it is set). So anyone who can push a branch could plant an entry that production restores: the console's bundle, the packages it and the docs bundle, and with #2425 the built-in schemas and the docs' generated sources. The Codex review on #2425 showed it for the launcher, which #2425 leaves uncached.This turns on turbo's artifact signatures:
turbo.json:remoteCache.signature: true(turbo signs each upload withTURBO_REMOTE_CACHE_SIGNATURE_KEYand takes an entry it cannot verify for a miss) andfutureFlags.longerSignatureKey: true. Without the flag, turbo 2.11.7 accepts an empty key with a warning, and two empty-key runs verify each other's entries. With it, a key under 32 bytes fails any run that uses the remote cache.ci-turboonmainsign with production's key. Previews and every otherci-turborun sign with the previews' key.ci-turbo.yml: the job takes its key from the GitHub environmentturbo-cache-main(onmain) orturbo-cache-branches(anywhere else), withdeployment: falseso no deployment is recorded. A step after the OIDC token step copies the key intoGITHUB_ENV, so the setup actions and the install never see it. Without a key, the job falls back to the local cache with a warning.CACHE_SIGNER(mainorbranches, inglobalEnv) keeps the two CI populations' hashes apart, asVERCEL_TARGET_ENVdoes on Vercel. Without it, main's runs and branch runs would keep rejecting and re-uploading each other's entries.turborepo.md(who holds which key, the gotchas), the plan's "Who may write to the cache" plus decision 11, and the runbook's variable table and a "Cache signatures" bullet.Secrets to add before merging
Generate two keys on a trusted machine, each with
openssl rand -hex 32: production's key and the previews' key. Nothing in this PR reads or sets them.zitadel, projectcloudTURBO_REMOTE_CACHE_SIGNATURE_KEYTURBO_REMOTE_CACHE_SIGNATURE_KEYzitadel/nextgen, new environmentturbo-cache-mainTURBO_REMOTE_CACHE_SIGNATURE_KEYmainturbo-cache-branchesTURBO_REMOTE_CACHE_SIGNATURE_KEYturbo-cache-main's branch rule before its secret. GitHub creates any environment a workflow names, without rules.deployment: falsejob fails outright under custom rules.Production/Previewenvironments. Vercel's deployment statuses use them, and they have no branch rules.artifact signature errorand build everything;ci-turbowarns and uses its local cache.cache hitagain.Validation
All runs used turbo 2.11.7 from this checkout, against a local fake remote cache: a Node server for turbo's
/v8/artifactsAPI that stores each upload with itsx-artifact-tag. Every run wasturbo run build --filter=@zitadel/design-tokens(generate+build) withTURBO_CACHE=remote:rw, as on Vercel, and two random 32-byte keys.VERCEL_TARGET_ENV=productionwrote both tasks under production's hashes. The production-key run then reportedcache missfor both, rebuilt them and re-signed them; the next production run had 2/2 hits.CACHE_SIGNER=main(production's key) andCACHE_SIGNER=branches(the previews' key) give different hashes, and each hit its own entries on rerun. A previews'-key run withCACHE_SIGNER=mainuploaded under main's hashes, and main's next run rejected those entries.WARNING artifact signature error, nothing uploaded.TURBO_CACHE=local:rw(the workflow's fallback): exit 0.turbo run <ci-mode's 50 graph tasks> --dry=jsonresolves all 389 tasks withCACHE_SIGNERunset,mainandbranches;@zitadel/console#buildgets three different hashes.GITHUB_ENVor warns and exits 1.node scripts/check-pr-title.mjsandnode scripts/check-changesets-status.mjs --base origin/mainboth pass.ci-turboitself (a run would create the environments), a Vercel build, and Vercel's real remote cache. How Vercel treats a second upload under an existing hash is unknown; the fake cache replaces it.Release notes / changeset
No changeset required — no shipped behavior changed.
Notes
gh-readonly-queue/branches. One community thread says write access can push them, one report says GH006, and this repo has no ruleset on them. If a writer can create one, a rule admittinggh-readonly-queue/**hands them production's key (gh workflow run ci-turbo.yml --ref gh-readonly-queue/main/x). To trust the queue once that is settled (a check from a write-only account, or a ruleset the merge queue bypasses), addgh-readonly-queue/main/*to the rule andmerge_groupto the workflow's twogithub.ref == 'refs/heads/main'expressions. Nothing depends on it today:ci-turbois not required, and onmainthe queue does not run it.maintoday, a by-hand run on a branch starts cold.git merge-tree, two hunks):turbo.json: keepremoteCacheand onefutureFlagsholding bothaffectedUsingTaskInputsandlongerSignatureKey. Turbo silently keeps only the last of twofutureFlagskeys, which is why this PR puts its block at the same spot as build: stop docs and test edits from re-running the task graph, and let turbo select what ci-turbo runs #2420's.ci-turbo.ymlheader: take build: stop docs and test edits from re-running the task graph, and let turbo select what ci-turbo runs #2420's text, but its "so that the remote cache holds main's results for the branches cut from it" no longer holds. Main's results now serve main's next run, and branches restore the merge queue's.@zitadel/cloud#build(the launcher) could be cached again, since no branch can make production restore it. Left uncached here.turbo-cache-maincould hold a third key and production's key would live on Vercel alone. This PR follows the plan's two keys.🤖 Generated with Claude Code