Repository navigation
Conversation
This was referenced Nov 26, 2026
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | e41c0ad | Nov 26 2026, 08:53 PM |
|
Your organization has run out of review credits. Add credits to resume code reviews. |
tnkuehne
added a commit
that referenced
this pull request
Nov 27, 2026
The runtime encrypts what it stores itself (app secret snapshots, the keys behind `WIDEFLEET_KEYS`, the workload signing ring) and the managed OAuth values that clients hold. It used one raw key, `WIDEFLEET_SECRETS_KEY`, in a format that names no key version, so the key could not be rotated: replacing it made every stored value unreadable, including app keys that exist nowhere else. ## Changes - **Keyring.** `WIDEFLEET_SECRETS_KEYS` is a JWK Set in the control plane's keyring format, active version first. The format helpers move from `secret-encryption.ts` to `@platform/contracts/keyring`, so both share one parser. - **Format.** Values are compact JWE, `dir` + `A256GCM`, with the key version as `kid` and the value's object path or purpose as a protected `ctx`. Opening requires the context the reader expects, so a value cannot be moved to another object or purpose. - **Bearer values.** Managed OAuth access placeholders, refresh grants and state tickets open only under the active version, so a new active version retires them. - **App keys.** A key's exact 32 bytes are sealed with its full path as context, so existing app ciphertexts and signatures stay valid. - **Rewrite.** The runtime management endpoint `/.well-known/widefleet/rekey` seals stored values again under the active version, one bounded page per request. It opens every value, also one that already names the active version, and writes only if the object is still the one it read; deleted objects stay deleted and no app key is created. Whatever deploys the runtime drives the pages in one pass once the runtime is live: `deploy-hosted` at the end of a deployment, after waiting for the runtime to report the keyring's active key version (a keyring change can keep the release), and the agent after each committed Runtime job, whose message reports the counts. `deploy-hosted` exits nonzero and the job message says so if a value was unreadable or changed during the pass. New values are always sealed under the active version, so a pass without either leaves every value under it. The earlier Ed25519 ring at `workload/signing-keys.json` is not read and is left as it is. - **Earlier values.** `legacy-runtime-ciphertext.ts` reads values written before the keyring with the active version's bytes until they are rewritten, including snapshots that still carry a fingerprint, which the rewrite drops. A later PR removes it. - **Provisioning.** `deploy-hosted` validates and deploys `WIDEFLEET_SECRETS_KEYS`. The agent generates a keyring per organization at `organizations/<id>/app-secrets-keyring.json` instead of the earlier hex key. - **Docs** are in #431, merged after the release. ## Upgrade - **Hosted:** supply a keyring whose only key holds the bytes of the current `WIDEFLEET_SECRETS_KEY` in unpadded base64url, and deploy; the deployment rewrites runtime storage. Deployments keep secrets they do not name, so delete the earlier `WIDEFLEET_SECRETS_KEY` secret from the runtime Worker once with `wrangler secret delete`. Managed OAuth values still in the earlier format when that reader is removed need a new authorization. - **Self-hosted:** installations from before the keyring are not upgraded in place. Their runtime storage, including the workload signing ring and app keys, is encrypted with the earlier key, which the agent no longer provides to any runtime release. They are set up anew with matching agent and runtime releases. The next PR in this stack derives one key per purpose from each version. Both ship in one release, so no deployment writes this PR's root-key format. ## Testing - `pnpm check` - `packages/app-runtime`: `secrets.test.ts` (context binding, earlier versions for stored values, active version only for bearer values, values before the keyring), `rekey.test.ts` (rewrite of every stored kind with unchanged content and app key bytes, unreadable values, concurrent writes, deletions, paging), `keys.test.ts` (sealed record, same key bytes from a record before the keyring), `oauth.test.ts` (retired values after rotation; size limits), `workload-keys.test.ts`, `oauth-metadata-document.test.ts`, `template-oauth.test.ts` - `apps/control-plane`: `runtime-rekey.test.ts` (page loop); `cloudflare/runtime.test.ts` status checks with the key version; `app-services-runtime.test.ts` on workerd, including a stored snapshot from before the keyring rewritten through the management endpoint; `managed-oauth-runtime.test.ts`; `cloudflare/runtime.test.ts -t secrets`; `cloudflare/deployment.test.ts -t "private secrets"` - `cargo test -p platform-agent --lib runtime::`, `cargo test -p platform-agent --bin platform-agent rekey` - The rewrite step of `deploy-hosted` was not run against a Hosted installation.
tnkuehne
added a commit
that referenced
this pull request
Nov 27, 2026
Stacked on #428. Each runtime keyring version encrypted every kind of value with its own 32 bytes: app secret snapshots, the keys behind `WIDEFLEET_KEYS`, the workload signing ring and the managed OAuth access, refresh and state values. A weakness in how one of them uses the key, for example a nonce reuse, would then reach all of them. ## Changes - **Purpose keys (`secrets.ts`).** Each version derives one AES-256-GCM key per purpose with HKDF-SHA256 (RFC 5869): a fixed 32-byte zero salt and the label `widefleet runtime <purpose> v1`. The purposes are a closed list: `app-secrets`, `app-keys`, `workload-keys`, `oauth-access`, `oauth-refresh` and `oauth-state`. - **Key IDs.** `kid` is `<version>:<purpose>`. Opening accepts only the purpose the caller expects, and never the root key itself. Version IDs cannot contain a colon, so the scheme is unambiguous. - **Callers.** Snapshot preparation and reads, app keys, the workload ring, managed OAuth and the rewrite pass their purpose. The rewrite counts a value as current only under the active version's key for its purpose. - **Docs** are in #431. This PR ships in the same release as #428, so no deployment writes the root-key format of #428 and the rewrite runs once. ## Testing - `pnpm check` - `packages/app-runtime`: `secrets.test.ts` (a value of one purpose does not open for another, also with the purpose renamed in its header; the root key opens nothing), `rekey.test.ts`, `keys.test.ts`, `oauth.test.ts`, `workload-keys.test.ts`, `oauth-metadata-document.test.ts`, `template-oauth.test.ts` - `apps/control-plane`: `app-services-runtime.test.ts` on workerd, `managed-oauth-runtime.test.ts`, `cloudflare/runtime.test.ts -t secrets` <!-- greptile_comment --> <!-- greptile_summary --> <h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge; no blocking issue remains.</rp></ruby><a href="https://app.greptile.com/api/retrigger?id=120995216&sig=fc88eb82f480fd83d61f191706434ff82974403bb58fb65eedcc940c10e842ed"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F429&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier: plus" title="Review tier: plus" src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-plus.svg?v=3" height="12"></sup></h2> <!-- greptile-impact-verdict --> The PR appears safe to merge; no blocking issue remains. <details open><summary><h3>Summary</h3></summary> Derives a separate encryption key for each runtime purpose and includes that purpose in `kid`. - Runtime values use separate encryption keys for each purpose. - The storage rewrite checks each value against its purpose key. </details> <details open><summary><h3>Diagram</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart LR Root["Runtime key version"] --> HKDF["HKDF-SHA256 with purpose label"] Purpose["Caller supplies purpose"] --> HKDF HKDF --> Key["Purpose-specific AES-GCM key"] Key --> Seal["Encrypt value"] Context["Expected context"] --> Seal Seal --> Value["JWE with version:purpose and context"] Value --> Open["Open with expected purpose and context"] Key --> Open ``` </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (8) · Last reviewed commit: ["Drop an import the removed refresh test ..."](b963da6) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the runtime keyring from #428 and the per-purpose keys from #429. Merge after the release that contains them.
Changes
reference/runtime.md, new section "Encryption keys".PLATFORM_ENCRYPTION_KEYS, and where hosted and self-hosted installations keep it.widefleet runtime rekey.widefleet runtime rekey. Self-hosted installations from before the keyring are set up anew with matching agent and runtime releases.reference/runtime.md: the CLI example listswidefleet runtime rekey.guides/app-services.md: backups name the runtime keyring instead of the single key.self-hosting/installation.md: the hosted configuration note links the runtime keyring.

Confidence Score: 5/5
No blocking issue was established in the latest changes.Summary
Documents the runtime keyring, key rotation and the upgrade from the earlier single key.
Reviews (2) · Last reviewed commit: "Describe the single rekey pass and the e..." · Reviewed by Greptile