Skip to content

Write app secrets without a fingerprint of their values - #419

Merged
tnkuehne merged 3 commits into
mainfrom
fix/app-secrets-overwrite
Nov 26, 2026
Merged

tnkuehne merged 3 commits into
mainfrom
fix/app-secrets-overwrite

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Each prepared app secret revision in app-secrets/<appId>/<revision>.json stored an unkeyed SHA-256 of its plaintext values next to the ciphertext. Anyone who could read the bucket could test guessed values against it offline. The hash served only one purpose: rejecting a second preparation of the same revision with other values (App secret revision is immutable).

That case does not happen in normal operation. Only the control plane can call the preparation endpoint, and it reads a revision together with its values from the same app row, while every change increments the revision. A retried deployment therefore always sends the same values. A used revision with other values comes only from a control plane that lost its revision counter, for example after a database restore. The check then failed every deployment of the app until the counter passed the revisions left in storage.

Changes

  • prepareAppSecrets (app-secrets.ts). Preparation encrypts the values and writes the revision's file, without a fingerprint, comparison or conditional write. A retry writes the same values again; after a restore, the control plane's current values replace the earlier ones.
  • Reading ignores the fingerprint field that files written before this change still contain, until their revision is prepared again or the app is removed.

Rollback

Runtimes before this change require the fingerprint field when they read or prepare a revision. Once an app is deployed with this runtime, its secret file has no fingerprint, so rolling the runtime back to an earlier version breaks that app's secret reads and deployments. Rollbacks to earlier runtimes are not supported across this change. Updating the runtime to this version again restores them, because it reads files written by either version.

Testing

  • pnpm check
  • tests/app-services-runtime.test.ts on workerd: preparing a used revision with other values succeeds, the app reads the new value, and no stored file contains a fingerprint. The case fails without the change with App secret revision is immutable.
  • tests/cloudflare/runtime.test.ts: refreshes secrets in warm pinned workflows

🤖 Generated with Claude Code

Each prepared secret revision stored an unkeyed SHA-256 of its plaintext
values next to the ciphertext, only to reject a second preparation of the
revision with other values. The control plane reads a revision together
with its values, so a retry always sends the same values. Other values
for a used revision come only from a control plane that lost its counter,
for example after a database restore, and the check then blocked its
deployments. Preparation now writes the current values for the revision.
Comment thread packages/app-runtime/src/app-secrets.ts Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 973e3b9 Nov 26 2026, 10:52 AM

@tnkuehne
tnkuehne merged commit 835697c into main Nov 26, 2026
27 of 29 checks passed
@tnkuehne
tnkuehne deleted the fix/app-secrets-overwrite branch November 26, 2026 14:52
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.

1 participant