Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Breaking:** guest: a data disk left at older KMS key epochs is no longer
migrated after a key rotation; boot stops instead. Start such apps from a
fresh data disk. Migration keeps the volume key, which the old root and any
copy of the old LUKS header reveal, so a migrated disk stays readable and
writable by whoever holds them. `requirements.unsafe_allow_disk_migration`
restores migration and is strongly discouraged; it has to be set in a new
compose approved in the old and the current app epoch rows.
- **`vmm-cli update --compose` takes an app compose file.** It sends the
`app-compose.json` written by `vmm-cli compose` unchanged instead of a Docker
Compose file patched into the stored one, and `--prelaunch-script` and
Expand Down
5 changes: 4 additions & 1 deletion docs/app-key-epochs.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ keys already delivered. Supplied `trusted_ca` always pins the KMS connection,
regardless of epoch selection; historical responses cannot replace that pin.

The guest migrates disk headers and environment ciphertext if either dimension
changes and rejects future epochs in either dimension. LUKS tokens record both
changes and rejects future epochs in either dimension. Disk migration also
requires `requirements.unsafe_allow_disk_migration` in the app compose, which is
strongly discouraged; see
[the emergency rotation protocol](kms-emergency-key-rotation-protocol.md#5-os-slot-migration-and-luks-header-metadata). LUKS tokens record both
epochs (missing app epoch means zero). Rekeying replaces the keyslot wrapping key;
it does not rotate the volume encryption key or erase host snapshots. Once a disk
header carries an epoch token, older guest images reject that header as malformed;
Expand Down
23 changes: 21 additions & 2 deletions docs/kms-emergency-key-rotation-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ copy the header to tmpfs -> validate the copy
initialization label set -> reformat (the disk holds no data yet)
token_or_0 > current -> refuse
current key unlocks a keyslot of the copy -> finish
otherwise, token_or_0 < current -> old keys of epoch token_or_0
otherwise, token_or_0 < current -> refuse unless
unsafe_allow_disk_migration
-> old keys of epoch token_or_0
-> check they unlock the recorded slot (token slot, else slot 0)
-> luksKillSlot any other slot
-> luksAddKey (old key authorizes the new key in the free slot)
Expand All @@ -181,6 +183,21 @@ cleared only after the filesystem exists, so such a disk is reformatted. Never
format on unlock failure. Invalid or unsupported metadata requires recovery.
The disk is opened only with the last validated in-memory copy.

The guest refuses such a disk unless the app compose sets
`requirements.unsafe_allow_disk_migration`, which is strongly discouraged.
Re-keying keeps the volume key. The old root and any copy of the old LUKS
header reveal it, and every host, storage backend or snapshot that saw the disk
before the rotation has such a copy, since the header is plaintext. Whoever
holds both can read and modify a migrated disk at any time, before or after the
migration, and no later check can tell. Disabling the flag afterwards does not
help: the disk is then at the current epochs and never migrates again. Use it
only when the old root is known not to have leaked, or when losing the data is
worse than exposing it to whoever holds that root; otherwise start from a fresh
disk and restore data at the application layer. A resumed migration whose
current key already unlocks a keyslot needs no flag. Refusing historical keys to
the new image in the old policy row also blocks migration, but for every app and
together with env migration and historical `GetKey`.

No extra reboot is required. Historical material is confined to the migration
step, not persisted or passed to applications.
Old OS implementations with the existing validator reject a token-bearing disk;
Expand Down Expand Up @@ -312,7 +329,9 @@ Protect root storage and independent admin access.
3. Rotation-onboard one node, register its new epoch, then ordinary-onboard peers.
Authorize new KMS images before removing old OS images; do not rotate again
during the cutover.
4. Boot new OS with business services held by orchestration. Migrate slots and
4. Boot new OS with business services held by orchestration. Start apps from
fresh data disks; `requirements.unsafe_allow_disk_migration` keeps an old
disk but leaves it exposed to the old root (section 5). Migrate slots and
complete platform env replacement; confirm app readiness. Ingress closure alone does
not stop workers, cron jobs, queues, or outbound database/wallet writes.
5. Start gateways with fresh data directories/KV namespaces and clean WireGuard
Expand Down
1 change: 1 addition & 0 deletions docs/security/cvm-boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ This is the main configuration file for the application in JSON format:
| storage_fs | 0.5.5 | string | Filesystem type for the data disk of the CVM. Supported values: "zfs", "ext4". default to "zfs". **ZFS:** Checksums every block, so a modified block fails the read. **ext4:** Lower overhead and faster I/O for database workloads; checksums metadata but not file data, so a modified block is not detected. |
| storage_discard | 0.6.0 | boolean | Return unused data-disk blocks to the host. Defaults to `true` so encrypted sparse images track live data instead of historical writes. Set to `false` if revealing filesystem allocation and deletion patterns to the host is unacceptable. |
| requirements.ephemeral_data_disk | 0.6.2 | boolean | Start every boot with an empty data disk. The guest formats the data disk before any app code runs, so app code sees nothing an earlier boot wrote. With storage encryption on (the default), each format generates a fresh LUKS volume key, so earlier ciphertext, including a disk image the host rolled back, can no longer be decrypted. With encryption off, old blocks may remain readable on the raw device. Images and container layers live on the data disk, so every boot pulls them again. Defaults to `false`. Requires string `manifest_version: "3"`. |
| requirements.unsafe_allow_disk_migration | 0.6.7 | boolean | **Strongly discouraged.** Let the guest re-key a data disk left at older KMS key epochs after a key rotation instead of refusing to boot on it. Re-keying keeps the volume key, which the old root and any copy of the old LUKS header (held by every host or snapshot that saw the disk) reveal, so whoever holds them can read and modify the disk for good, including after the migration; disabling the flag later does not help. Use a fresh data disk instead. Defaults to `false`. Requires string `manifest_version: "3"`. |
| swap_size | 0.5.5 | string/integer | The linux swap size. default to 0. Can be in byte or human-readable format (e.g., "1G", "256M"). |
| key_provider | 0.5.6 | string | Key provider type. Supported values: "none", "kms", "local", "tpm". GCP vTPM and AWS EC2 NitroTPM are part of their platform trust models. The Dstack platform can use VMM-managed swtpm for seal/unseal and restart persistence, but it offers no protection against the host and is intentionally not accepted by remote verifiers. |

Expand Down
13 changes: 13 additions & 0 deletions dstack/dstack-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@ pub struct Requirements {
/// disk before any app code runs, discarding what earlier boots left on it.
#[serde(default, skip_serializing_if = "is_false")]
pub ephemeral_data_disk: bool,
/// Let the guest re-key a data disk left at older KMS key epochs instead
/// of refusing to boot on it. Strongly discouraged: re-keying keeps the
/// volume key, which the old root and any copy of the old LUKS header
/// reveal, so whoever holds them can read and modify the disk for good.
#[serde(default, skip_serializing_if = "is_false")]
pub unsafe_allow_disk_migration: bool,
}

impl Requirements {
Expand All @@ -550,6 +556,7 @@ impl Requirements {
&& !self.health_check
&& self.health_status_file.is_none()
&& !self.ephemeral_data_disk
&& !self.unsafe_allow_disk_migration
}
}

Expand Down Expand Up @@ -852,6 +859,12 @@ impl AppCompose {
.is_some_and(|requirements| requirements.ephemeral_data_disk)
}

pub fn unsafe_allow_disk_migration(&self) -> bool {
self.requirements
.as_ref()
.is_some_and(|requirements| requirements.unsafe_allow_disk_migration)
}

pub fn key_provider(&self) -> KeyProviderKind {
match self.key_provider {
Some(p) => p,
Expand Down
6 changes: 6 additions & 0 deletions dstack/dstack-util/src/system_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3077,6 +3077,12 @@ impl<'a> Stage0<'a> {
}
if let Some(current) = kms_root_epoch(keys) {
let old_key = async |root, app| {
if !self.shared.app_compose.unsafe_allow_disk_migration() {
bail!(
"the data disk is at key epochs (root {root}, app {app}); \
set requirements.unsafe_allow_disk_migration to migrate it"
);
}
let old = self.shared.request_historical_keys(keys, root, app).await?;
Ok(hex::encode(&old.disk_crypt_key))
};
Expand Down
5 changes: 4 additions & 1 deletion sdk/go/dstack/compose_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ type Requirements struct {
// EphemeralDataDisk formats the data disk on every boot. Like HealthCheck,
// a false value must stay out of the manifest.
EphemeralDataDisk bool `json:"ephemeral_data_disk,omitempty"`
// UnsafeAllowDiskMigration lets the guest re-key a data disk left at older
// key epochs. Like HealthCheck, a false value must stay out of the manifest.
UnsafeAllowDiskMigration bool `json:"unsafe_allow_disk_migration,omitempty"`

GpuPolicy *GpuPolicy `json:"gpu_policy,omitempty"`

Expand Down Expand Up @@ -615,7 +618,7 @@ func (r *Requirements) UnmarshalJSON(data []byte) error {
delete(extra, key)
}
}
for _, key := range []string{"health_check", "ephemeral_data_disk"} {
for _, key := range []string{"health_check", "ephemeral_data_disk", "unsafe_allow_disk_migration"} {
if value, ok := extra[key]; ok && value == false {
delete(extra, key)
}
Expand Down
4 changes: 3 additions & 1 deletion sdk/js/src/get-compose-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface Requirements extends SortableObject {
health_status_file?: string | null;
/** Format the data disk on every boot. A false value is omitted when hashing. */
ephemeral_data_disk?: boolean;
/** Allow re-keying a data disk left at older key epochs. A false value is omitted when hashing. */
unsafe_allow_disk_migration?: boolean;
gpu_policy?: GpuPolicy;
}

Expand Down Expand Up @@ -140,7 +142,7 @@ function serializeFields(appCompose: AppCompose): AppCompose {
for (const field of ['platforms', 'tdx_measure_acpi_tables', 'launch_token_hash', 'health_status_file']) {
if (requirements[field] === null) delete requirements[field];
}
for (const field of ['health_check', 'ephemeral_data_disk']) {
for (const field of ['health_check', 'ephemeral_data_disk', 'unsafe_allow_disk_migration']) {
if (requirements[field] === false) delete requirements[field];
}
if (requirements.gpu_policy && typeof requirements.gpu_policy === 'object' && !Array.isArray(requirements.gpu_policy)) {
Expand Down
11 changes: 10 additions & 1 deletion sdk/python/src/dstack_sdk/get_compose_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(
health_status_file: Optional[str] = None,
gpu_policy: Optional[Dict[str, Any]] = None,
ephemeral_data_disk: bool = False,
unsafe_allow_disk_migration: bool = False,
**kwargs: Any,
) -> None:
"""Initialize a new ``Requirements`` instance."""
Expand All @@ -81,6 +82,7 @@ def __init__(
self.health_status_file = health_status_file
self.gpu_policy = gpu_policy
self.ephemeral_data_disk = ephemeral_data_disk
self.unsafe_allow_disk_migration = unsafe_allow_disk_migration
self._extra = dict(kwargs)
self._explicit_nulls: set[str] = set()

Expand All @@ -104,6 +106,8 @@ def to_dict(self) -> Dict[str, Any]:
result["health_status_file"] = self.health_status_file
if self.ephemeral_data_disk:
result["ephemeral_data_disk"] = True
if self.unsafe_allow_disk_migration:
result["unsafe_allow_disk_migration"] = True
if self.gpu_policy is not None:
result["gpu_policy"] = {
key: value
Expand Down Expand Up @@ -186,7 +190,12 @@ def __init__(
if isinstance(requirements, dict) and self.requirements is not None:
self.requirements._explicit_nulls = {
key
for key in ("health_check", "ephemeral_data_disk", "gpu_policy")
for key in (
"health_check",
"ephemeral_data_disk",
"unsafe_allow_disk_migration",
"gpu_policy",
)
if key in requirements and requirements[key] is None
}
self.bash_script = bash_script
Expand Down
1 change: 1 addition & 0 deletions sdk/tests/compose-hash-fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"requirements": {
"health_check": false,
"ephemeral_data_disk": false,
"unsafe_allow_disk_migration": false,
"gpu_policy": {
"rego": null,
"attest_gpu": true
Expand Down
Loading