Skip to content

Release 1.26.15: TC-3554 seal the epoch-0 root in root_wrap (DO NOT MERGE without Naomi's GO) - #670

Merged
samgbafa merged 10 commits into
mainfrom
feat/tc-3554-root-wrap-main
Nov 20, 2026
Merged

samgbafa merged 10 commits into
mainfrom
feat/tc-3554-root-wrap-main

Conversation

@samgbafa

@samgbafa samgbafa commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Release 1.26.15. Ready for review. DO NOT MERGE without Naomi's GO. Nothing deploys from this PR by itself.

This is release 1.26.15 for TC-3554, off main after #668 (v1.26.14, 3f66adcb). It replaces #669. The node's identity root (KMS root epoch 0) is sealed once into the database and opened from there on every later boot, so at runtime the node stops depending on the KMS serving epoch 0 or on the key-recovery sidecar.

This release ships on main's sidecar compose, unchanged (N0 template 70c71aa0acb7ebe157a1c1fac3e30fb3536b7cc21ba51d4013f905599c22ea4f). Its first boot seals the blob. The sidecar-free compose is release 1.26.16, in stacked draft #671 (feat/tc-3554-sidecar-free), gated on this release's seal and a restart.

Commits

  1. 709626c6 feat(node): seal the epoch-0 root in root_wrap; transport optional once sealed.

    • Table: root_wrap(id SMALLINT PK CHECK id = 1, wrapped, node_did, kms_root_epoch, created_at). Migration m20261120_000000_root_wrap covers PG and SQLite through a shared create_table().
    • Seal:
      • K_wrap = dstack GetKey("tinycloud/keys/primary-wrap") on the current root.
      • AES-256-GCM with a random 12-byte nonce.
      • AAD = "tinycloud/root-wrap/v1" || app_id || pinned DID.
      • Keys and plaintext are zeroized.
    • Boot (DstackKmsEpoch):
      1. Parse the pins, connect, CREATE TABLE IF NOT EXISTS root_wrap, read the row.
      2. If the row is absent: fetch the root through the transport, run the full verifier, then INSERT … ON CONFLICT DO NOTHING and re-read. If the row is present: no sidecar or KMS call, even when a transport is configured.
      3. Unseal, then check pinned expected_did, then EXPECTED_NODE_DID. Only after that do migrations and renewal_identity run.
    • Refusals: no blob and no transport, a tampered blob, or a blob that opens to another DID all refuse startup. The node fails closed and never falls back to the current root.
  2. fdd77177 and its revert a6f87fb0. The sidecar-free compose was first committed here. It is reverted so this release keeps main's compose byte-for-byte: the compose, the docker.yml N0 hash, the fixture, compose_mounts and the releasing.md hashes all equal main. It moves to 1.26.16.

  3. af95c4f2 Bobbie N1 and N4:

    • The node logs opened identity root from root_wrap at info level (event = "root_wrap_opened"; the only field is root_epoch; no key material or row contents) after the blob opens and passes every check.
    • open_wrapped moves the unsealed root into StaticSecret instead of copying it.
  4. fae43a00 and 182a5a40: Bobbie N1-N3, then Naomi's amendment:

    • The exact log text.
    • The release order.
    • The recovery runbook: back up the row before any delete, and never delete it while epoch 0 can't be fetched.
  5. 056c2121: releasing.md restore note. A backup restore carries the row. A fresh database is resealed on the sidecar compose's first boot; on a sidecar-free compose it refuses until one sidecar boot seals it.

  6. 030a1f8d Release 1.26.15, the same shape as Release 1.26.14: TC-3554 restore the node on its epoch-0 KMS root #668's f1ab627e:

    • tinycloud-node-server/Cargo.toml, Cargo.lock and test/m1-realdata-e2e/Cargo.lock move to 1.26.15.
    • CHANGELOG [1.26.15] with upgrade notes.
  7. c70ae664 ci(deploy): Naomi's guest compose check, modelled on openkey#643.

    • What it does: deploy-phala downloads the sha256-pinned docker compose v2.26.0 release binary, the version the dstack 0.5.15 guest runs. It runs config -q on the exact spliced compose sent to Phala, with placeholders for required ${NAME:?} inputs. This happens after "Validate and pin deployment image" and before the deploy.
    • Why: the guest's schema refused long-form devices, which stopped the witness boot. With this check, a compose like that fails the workflow before any CVM change.
    • Kept: the runner-compose config --quiet check in the deploy step stays.
    • Docs: a CHANGELOG line and a releasing.md bullet.
    • Tests: no test pins the step list, so no test files changed.

The renewal_identity reset fallback from #669 is dropped. renewal_identity still holds the original renewer, and the reset was ruled off the deploy path.

Release order (Naomi decides the rollout)

  1. Seal boot. Deploy 1.26.15 on the sidecar compose; only the image digest changes. The first boot logs sealed the node root into root_wrap.
  2. Restart that opens from the blob, still on the sidecar compose. It must log opened identity root from root_wrap and must not log fetched and verified the node root …, which would mean a key-recovery fetch.
  3. Only then merge and deploy 1.26.16, the sidecar-free compose.

Ordering nuance

To decide whether the blob is present, the node must reach the database first. So before the DID check, the database actions are connect, CREATE TABLE IF NOT EXISTS root_wrap and the read. The insert happens only after the fetched root passes the full verifier. Nothing else (other migrations, renewal_identity, any write) runs before the DID check, and the integration tests assert that root_wrap is the only table present after any refusal.

Re-key risk

K_wrap derives from the current KMS root. If Phala rotates the root again, the blob stops opening and the node refuses to start. The recovery runbook is in docs/tc-3554-kms-epoch-fetch.md:

  1. Before any delete, copy the root_wrap row out as a backup. It is ciphertext, so it is safe to keep.
  2. Confirm epoch 0 can still be fetched.
  3. Only then delete the row and boot once on the sidecar compose.

Never delete the row while epoch 0 can't be fetched. Open question: how long does Phala keep epoch 0 retrievable?

Rollback: rolling back to 1.26.14 after 1.26.15 has migrated crosses a schema migration and has not been reviewed.

DID-resolution guard

No new verify_signature or resolve calls. #668's issued_by_pin entry is unchanged.

Verification (local)

At c70ae664, the guest compose check:

  • test-deploy-recovery.py: 30 OK.
  • test-phala-os-guard.sh: all passed.
  • test-docker-tags.py: ok.
  • test-quota-authority.py: 26 OK.
  • The docker.yml YAML parses.
  • I extracted the new step's script and ran it locally with the downloaded binary, which passed the sha256 check. It exits 0 on this compose.

Run once at 030a1f8d. Rust is unchanged since then:

Check Result
cargo test -p tinycloud-node --features dstack --test kms_epoch_identity 17 passed
--test did_resolution_single_entry 10 passed
cargo fmt --all --check clean
cargo clippy -p tinycloud-node -p tinycloud-core --all-targets -- -D warnings clean
python3 scripts/ci/test-deploy-recovery.py 30 tests OK
node scripts/tc959-check.mjs passed
compose, its fixture and scripts/ against origin/main no diff (docker.yml differs only by the new step)

Earlier full run, on the same code before the log-text and doc commits:

  • tinycloud-node lib (dstack): 1137 passed.
  • tinycloud-core lib: 1217 passed. The PG concurrent-insert test skips locally and runs on Actions.
  • sql_identity_cli: 1 passed.
  • Clippy with dstack is clean apart from the existing items_after_test_module at routes/encryption.rs:874.

Test files touched (for the test-edit ruling)

  • tinycloud-node-server/tests/kms_epoch_identity.rs:
    • assert_never_asked_for_a_key becomes assert_never_asked_for_the_node_key; it allows only GetKey(tinycloud/keys/primary-wrap).
    • The fetch-failure tests now assert "only root_wrap exists, empty" instead of "database never opened".
    • did_mismatch_* becomes …_before_any_other_database_write.
    • no_transport_configured_refuses_before_any_call is replaced by no_blob_and_no_transport_refuses_startup.
    • New tests: a_sealed_root_boots_without_the_sidecar, a_tampered_blob_refuses_startup_without_fallback and an_unsealed_root_with_another_did_refuses_before_any_other_write.
    • a_sealed_root_boots_without_the_sidecar checks the startup log lines:
      • First boot: the fetched, sealed and opened identity root from root_wrap lines.
      • Restart that still has the sidecar: the opened line and neither the fetched nor the sealed line.
      • Then a boot without the sidecar.
  • tinycloud-node-server/src/dstack_kms.rs (unit tests):
    • exactly_one_transport_must_be_configured becomes at_most_one_transport_may_be_configured.
    • New tests: a_wrapped_root_opens_to_the_pinned_identity and a_wrapped_root_is_refused_unless_every_check_passes.
  • tinycloud-core/src/root_wrap.rs: a new module with new tests (known-answer vector, fresh nonce, tampered blob, wrong AAD, one row with the first insert winning, concurrent SQLite inserts, concurrent PG inserts on Actions).
  • scripts/tc959-docker.mjs: unchanged against main (the edit was reverted).

test-ruling: TC-3554

Details: TC-3554

…ional once sealed

- root_wrap table (migration m20261120_000000_root_wrap, PG + SQLite): one row
  (id = 1), wrapped = nonce || AES-256-GCM(K_wrap, root), node_did,
  kms_root_epoch, created_at.
- K_wrap = dstack GetKey("tinycloud/keys/primary-wrap") on the current root;
  AAD = "tinycloud/root-wrap/v1" || app_id || pinned DID. Keys and plaintext
  zeroized.
- DstackKmsEpoch boot: parse pins, connect, CREATE TABLE IF NOT EXISTS
  root_wrap, read. Absent: fetch + full verify through the transport, insert
  ON CONFLICT DO NOTHING, re-read. Then unseal and check the DID against the
  pins, then EXPECTED_NODE_DID, before migrations or any other write. No
  blob and no transport refuses; no fallback to the current root.
- Tests: seal/unseal vector, tampered, wrong AAD, one-row + concurrent
  insert (SQLite, PG when available), DID mismatch after unseal, no blob +
  no transport, sealed root boots without the sidecar, tampered blob, and
  ordering (no migration / renewal_identity before the DID check).

Details: TC-3554
…om root_wrap (DEPLOY ONLY AFTER A BLOB EXISTS IN PROD)

DEPLOY ONLY AFTER A BLOB EXISTS IN PROD. The blob is sealed by a boot of a
root_wrap release on 1.26.14's sidecar compose; this compose has no sidecar
and no transport, so with no blob the node refuses to start.

- docker-compose.dstack-postgres.yaml: remove the key-recovery service, its
  volume, depends_on and KEY_RECOVERY_SOCKET. Pins unchanged
  (KMS_ROOT_PUBKEY 0334c76e…e910e1, app id, epoch-0 DID).
- Lockstep: docker.yml n0_template_hash 6a577c6d… (raw 272f43b8…),
  docs/releasing.md N0 hash text and rollback note, byte-identical
  scripts/ci/fixtures/tc959-n0-compose.yaml, tc959-docker.mjs
  compose_mounts without key-recovery:/run/key-recovery.

Details: TC-3554
…the unsealed-root copy

Bobbie N1: info `opened the node root from root_wrap` (event
root_wrap_opened, root_epoch only; no key material or row contents) after
the blob opens and passes every check. kms_epoch_identity's
a_sealed_root_boots_without_the_sidecar asserts the fetched, sealed and
opened lines on the first boot, and on a restart still on the sidecar
the opened line with no fetch or seal.

Bobbie N4: open_wrapped moves the unsealed root into StaticSecret instead
of copying it, and zeroizes it on the short-root error.

test-ruling: TC-3554
Details: TC-3554
…behaviour

Bobbie N1-N3: gate the sidecar-free compose on a seal line and a
second sidecar-compose restart that logs the opened line and no fetch.
Recovery copies the root_wrap row out and confirms epoch 0 is still
fetchable before deleting it; deleting it with epoch 0 gone loses the
node identity for good (open question: how long Phala keeps epoch 0).
releasing.md: a backup restore carries the row; a fresh database refuses
until one sidecar boot seals it.

Details: TC-3554
…ease order and recovery

Naomi's amendment to Bobbie N1/N2:
- The blob-open log text is exactly "opened identity root from root_wrap"
  (event root_wrap_opened); kms_epoch_identity asserts the new text.
- The doc gives the release order: seal boot, then a restart that opens
  from the blob (confirmed by that line), then the sidecar-free compose.
- Recovery: copy the root_wrap row out as a backup before any delete;
  never delete it while epoch 0 cannot be fetched.

test-ruling: TC-3554
Details: TC-3554
….26.15

Reverts fdd7717. 1.26.15 ships on main's sidecar compose (N0 template
70c71aa0…) so its first boot seals the root_wrap blob; the sidecar-free
compose moves to the 1.26.16 PR, gated on that seal and a restart that
opens from root_wrap.

Details: TC-3554
…mpose

A backup restore carries the root_wrap row. A fresh database reseals on the sidecar compose's first boot; on a sidecar-free compose it refuses until one sidecar boot seals it (expected).

Details: TC-3554
- TC-3554: seal the epoch-0 root in root_wrap on the sidecar compose; later boots open it without the sidecar or KMS. One migration. Upgrade notes and release order in CHANGELOG.

Details: TC-3554
@samgbafa samgbafa changed the title TC-3554 next release: root_wrap blob, remove epoch-0 runtime dependence (DO NOT MERGE) Release 1.26.15: TC-3554 seal the epoch-0 root in root_wrap (DO NOT MERGE without Naomi's GO) Nov 20, 2026
@samgbafa
samgbafa marked this pull request as ready for review November 20, 2026 16:41
…ker compose v2.26.0

deploy-phala gains a step after "Validate and pin deployment image" and
before the deploy: it downloads the sha256-pinned docker compose v2.26.0
release binary (the dstack 0.5.15 guest's version) and runs `config -q` on
the exact spliced compose sent to Phala, with placeholders for required
`${NAME:?}` inputs. The guest's schema refused long-form `devices`, which
stopped the witness boot; this fails the workflow before any CVM change.
The runner-compose `config --quiet` in the deploy step stays.

Modelled on openkey#643. No test pins the step list.

Details: TC-3554
- The node's sealed identity root is not user data; no space or owner purge deletes it.
- Fixes space_purge_table_inventory on PostgreSQL (node_did matches the %_did rule).

Details: TC-3554
@samgbafa
samgbafa merged commit f4714e6 into main Nov 20, 2026
31 checks passed
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