@cloudhal/release-verify
v0.13.0
Published
Verifies a Cloudhal release bundle (RFC-0046 §2, §7, §11a): the Ed25519 release statement against pinned keys, the manifest, and every part of the tarball. Worker-safe; the attestation check is a Node-only subpath.
Readme
@cloudhal/release-verify
Verifies a Cloudhal release bundle before you deploy it. It follows RFC-0046 §2, §7 and §11a: hosts, tools and the cloudhal CLI share this one verifier. It runs on Workers, Node 24 and browsers.
import { releaseAssetUrls, verifyRelease } from "@cloudhal/release-verify";
const release = await verifyRelease({
request: { version: "0.9.0" }, // what you asked for: a signed older release is refused
statement, signature, manifest, // the exact downloaded bytes (Uint8Array)
tarball: () => fetchTarballStream(), // opened twice: digest first, then entries
planVersion: 1, // the highest plan version your deployer supports
});
for await (const entry of release.entries()) {
// { worker, kind, path, type?, bytes }: verified against the signed manifest
}
// Activate the deployment only after the loop has finished without an error.What it checks
- Sizes. The statement is at most 4096 bytes, and the signature is exactly 64.
- Signature. Ed25519 over the exact statement bytes, with a trusted key for
signing.keyId. - Request. The statement is for the requested version and channel.
- Statement. Its schema, through the precompiled validator, plus RFC-0046 §2 invariants 1 to 3 and 6.
- Manifest.
- Its size and SHA-256 equal the statement's.
- Its schema and invariants 4 and 5.
- The
release-statement.sigsignature form. planVersion.- Every listed path, and §7's limits.
- Tarball. Its size and SHA-256 equal the statement's.
Then entries() re-reads the tarball. It refuses:
- an entry the manifest does not list, or one whose size or SHA-256 differs from its listing;
- a missing entry;
- anything outside §7's tar format;
- an unsafe path:
..,., an empty segment, a backslash, a control character, more than 512 bytes, or two paths that collide after case folding.
There is no soft-fail mode. Every refusal is a ReleaseVerifyError with a stable code (ERROR_CODES).
Keys
PINNED_KEYS holds the keys of docs/security/release-signing-keys.md as they were when this version was published. It cannot learn about later revocations by itself.
You can only reduce trust: pass revoked: ["<keyId>"] to withdraw a key. Passing your own keys map replaces the table, so treat that as a reviewed change.
Key list and yank list (RFC-0046 §9)
keys.json (signed by an offline root) and yanked.json (signed by a yank key) live at https://cloudhal.dev/.well-known/cloudhal/, each with its .sig. Fetch all four on every run, verify them, and merge them into the keys you pin. They can only take trust away:
import { mergeTrust, PINNED_KEYS, verifyKeys, verifyRelease, verifyYanked } from "@cloudhal/release-verify";
const keys = await verifyKeys({ document: keysJson, signature: keysSig }); // pinned root, fresh
const yanked = await verifyYanked({ document: yankedJson, signature: yankedSig, keys }); // stale → stale-yank-list
await verifyRelease({ ...input, keys: mergeTrust(PINNED_KEYS, { keys, yanked }), yanked });Expiry. A statement's
createdAtmust lie within its key's[notBefore, notAfter]. AfternotAfter, the key verifies only while a freshkeys.jsonlists it asretiring. With pinned keys alone, the release is refused withkey-expired.Yanking. A yanked version is refused (
yanked), and a key thatyanked.jsonrevokes is refused (key-revoked).Keep state if you can. Pass the
memoryyou stored toverifyKeysandverifyYanked, and storerememberYanks(yanked, keys, memory)after every accepted pair. Refused:- a list that goes back in
serial, or drops a version or key you have already seen yanked or revoked (stale-yank-list); - a
keys.jsonolder than the newest one you have seen (key-list-invalid), so a replayed list cannot bring back a revoked yank key; - a list signed by a yank key a root list revoked or replaced (
yank-list-invalid); - a list from another yank key, unless a newer
keys.jsonreplaces the remembered one (stale-yank-list).
Without memory, a stolen yank key could undo yanks for you until the root rotates it. A
keys.jsonlists at most one active yank key.- a list that goes back in
Not yet published.
PINNED_ROOTSis empty until the root is generated. Until thenverifyKeysrefuses every list, unless you passroots.
The second factor
The Node-only subpath @cloudhal/release-verify/attestation checks the GitHub build-provenance attestation of the tarball, the manifest and the statement. It needs gh 2.68.0 or newer, signed in. It returns verified or failed, or unavailable when gh is missing, too old, or signed out.
import { verifyAttestation } from "@cloudhal/release-verify/attestation";
const r = await verifyAttestation({ dir, version: "0.9.0", commit: release.statement.commit });Scopes
missingScopes(manifest, granted) compares Cloudflare scope ids exactly, with one exception: workers-scripts.admin covers workers-scripts.edit, which manifests up to v0.9.0 name (RFC-0046 §3).
