Repository navigation
Conversation
- keys.type = DstackKmsEpoch (dstack builds): RA-TLS client cert signed by the KMS temp CA
(legacy quote/event-log extensions), GetAppKey for the pinned root epoch over TLS pinned to
the KMS CA (leaf issued directly by it, special usage kms:rpc). Fail-closed checks before the
database connects: root_epoch == pin and app_epoch == 0 (both required), low-S k256_signature
by the pinned epoch root over keccak256("dstack-kms-issued:" || app_id || app_pub), derived
node DID == keys.legacy.expected_did. No fallback to GetKey or another epoch.
- keys.expected_node_did (any key source): startup refuses another DID before the DB opens;
resolve_identity_state refuses it for every caller, the control plane included.
- docs/tc-3554-kms-epoch-fetch.md: the protocol OpenKey mirrors (openkey #640).
- tests/kms_epoch_identity.rs: fake guest agent + fake KMS (epochs 0/1) against the real binary.
- backup_identity bails for keys.type = DstackKmsEpoch before resolving (no KMS fetch): the epoch-0 root is a migration bridge on an exposed KMS root, re-key instead of exporting. - Covers the control-plane backup route (service.rs) through backup_identity.
…ecar - keys.legacy.key_recovery_socket selects Phala's key-recovery sidecar (unix socket GET /v0/key, root_epoch pin, app_epoch=0); kms_url+kms_ca_cert keep the direct RA-TLS transport. Exactly one transport, no runtime fallback. - Verifier on the sidecar answer: api v0, epochs present and pinned, public_key == pub(key), app_pub recovered from signature_chain[0], signature_chain[1] checked as the KMS issuance signature under the pinned epoch root, DID pin. The chain does not prove path->key; the DID pin does. - Direct KMS GetAppKey now sends app_epoch 0 explicitly. - Spec: transport A section, new vectors; fake-sidecar harness cases.
…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
…EPLOY ONLY AFTER A BLOB EXISTS IN PROD) DEPLOY ONLY AFTER A BLOB EXISTS IN PROD. This compose has no key-recovery sidecar and no transport: the node opens its epoch-0 root from the database's root_wrap blob, sealed by a boot of the sidecar compose (45de2e9), and refuses to start while there is none. Pins unchanged; KMS_ROOT_PUBKEY is still the UNSET_ placeholder (P2), so this compose refuses to boot until it is filled in. Details: TC-3554
keys.legacy.renewal_reset (TINYCLOUD_KEYS__LEGACY__RENEWAL_RESET__
{FROM_RENEWER_DID,FROM_EPOCH,TO_RENEWER_DID}), optional, unset by default.
After the identity checks and migrations, before TinyCloud initializes the
renewer identity, one transaction runs
UPDATE renewal_identity SET renewer_did = to, epoch = 1
WHERE id = 1 AND renewer_did = from AND epoch = from_epoch.
to_renewer_did must be the served root's renewer, or startup refuses. Any
other stored state is untouched and startup behaves as today. Logs only
whether it applied.
Tests: core exact-from-state / one-shot / other states untouched / epoch 0
refused; integration (wrong to-DID refuses and leaves the row, exact state
resets to epoch 1, other state bumps as before); config env parsing.
Details: TC-3554
…y reset" This reverts commit 49c3b65. renewal_identity still holds the original renewer (Sam's read, 14:44Z), so there is no from-state to reset, and the reset is ruled off the deploy path. No dead config path in this release. Details: TC-3554
Contributor
Author
Contributor
Author
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.
DO NOT MERGE. Draft. Nothing deploys from this PR.
Next node release for TC-3554: the node identity (KMS root epoch 0 app root) is sealed once in the database and opened from there on every later boot, so runtime no longer depends on the KMS serving epoch 0 or on the key-recovery sidecar.
Stacked on
feat/tc-3554-restore-build(f835b52, 027cdfc, c59c10c are not on main); will be rebased onto main once #668 merges. The new work is the last commits below.Commits
659ea844feat(node): seal the epoch-0 root inroot_wrap; transport optional once sealedroot_wrap(id SMALLINT PK CHECK id = 1, wrapped, node_did, kms_root_epoch, created_at), migrationm20261120_000000_root_wrap(PG + SQLite, sharedcreate_table()).K_wrap= dstackGetKey("tinycloud/keys/primary-wrap")(current root). AES-256-GCM, random 12-byte nonce,AAD = "tinycloud/root-wrap/v1" || app_id || pinned DID. Keys and plaintext zeroized.DstackKmsEpoch): parse pins → connect →CREATE TABLE IF NOT EXISTS root_wrap→ read.INSERT … ON CONFLICT DO NOTHING→ re-read.expected_did→EXPECTED_NODE_DID. Only after that do migrations andrenewal_identityrun.c3454c45deploy(compose):docker-compose.dstack-postgres.yaml,DstackKmsEpochpins with no sidecar and no transport. Deploy only after a blob exists in prod.KMS_ROOT_PUBKEYis still theUNSET_placeholder (P2).49c3b65ffallback renewal_identity reset, reverted byf7887be0: renewal_identity still holds the original renewer, so there is no from-state; ruled off the deploy path. Net tree carries no reset code or config.Ordering nuance
Deciding "blob present?" needs the database, so the first database action is connect +
CREATE TABLE IF NOT EXISTS root_wrap+ read, before the DID check. TheON CONFLICT DO NOTHINGinsert happens only after the fetched root passes the full verifier. Nothing else (other migrations,renewal_identity, any write) runs before the DID check. Integration tests assert the only table present after any refusal isroot_wrap.Risk
K_wrapcomes from the current KMS root. If Phala rotates the root again, the blob stops opening and the node refuses to start. Recovery: delete the row and boot once with a transport (documented).Verification (local)
cargo test -p tinycloud-node --features dstack --test kms_epoch_identity: 18 passed (new: sealed root boots without sidecar; tampered blob; unsealed other-DID ordering; no blob + no transport). The renewal-reset test was reverted with the fallback.cargo test -p tinycloud-node --features dstack --lib: 1137 passed.--test sql_identity_cli: 1 passed.cargo test -p tinycloud-core --lib: 1218 passed before the revert (root_wrap 7, of which the PG concurrent-insert test skips locally and runs on Actions).cargo clippy -p tinycloud-node -p tinycloud-core --all-targets -- -D warnings: clean. With--features tinycloud-node/dstackit is clean apart from aclippy::items_after_test_moduleinroutes/encryption.rs:874, which was already there and is untouched here (allowed for that run only).cargo fmt --all --check: clean.Test files touched (for the test-edit ruling)
tinycloud-node-server/tests/kms_epoch_identity.rs: changed existing tests.assert_never_asked_for_a_keyis nowassert_never_asked_for_the_node_key. It allows onlyGetKey(tinycloud/keys/primary-wrap).root_wrapexists, empty" instead of "database never opened". Thedid_mismatch_*tests are renamed…_before_any_other_database_write.no_transport_configured_refuses_before_any_callis replaced byno_blob_and_no_transport_refuses_startup.a_sealed_root_boots_without_the_sidecar,a_tampered_blob_refuses_startup_without_fallbackandan_unsealed_root_with_another_did_refuses_before_any_other_write.tinycloud-node-server/src/dstack_kms.rs(unit tests):exactly_one_transport_must_be_configuredis nowat_most_one_transport_may_be_configured: no transport parses asNone.a_wrapped_root_opens_to_the_pinned_identityanda_wrapped_root_is_refused_unless_every_check_passes.tinycloud-core/src/root_wrap.rs: new module with new tests.test-ruling: TC-3554
Details: TC-3554