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
15 changes: 8 additions & 7 deletions docs/onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,15 @@ The KMS VM ID is printed by `dstackup install` when it creates or reuses the KMS

### Upgrading the local KMS to root epochs

Upgrade the bundled `dstack-auth` together with the KMS. Before normal key release,
set `kmsContractAddr` in the host's `auth-allowlist.json` to the KMS's attested app ID
and register the verified bootstrap CA/k256 public keys in `rootEpochs` (epoch zero).
Use the bootstrap evidence to verify these keys; do not trust an unauthenticated
metadata response. Set `currentRootEpoch` to the active registered epoch (initially
Fresh `dstackup install` runs deploy KMS 0.6+ and automatically verify the KMS
bootstrap attestation before recording `kmsContractAddr` and `rootEpochs[0]` in
`auth-allowlist.json`. When upgrading an older local install, upgrade the
bundled `dstack-auth` together with the KMS, set `kmsContractAddr` in the host's
`auth-allowlist.json` to the KMS's attested app ID, and register the verified
bootstrap CA/k256 public keys in `rootEpochs` (epoch zero). Use the bootstrap
evidence to verify these keys; do not trust an unauthenticated metadata
response. Set `currentRootEpoch` to the active registered epoch (initially
zero). See [root registration and rotation](deployment.md#rotating-kms-root-keys).
The local installer does not register these keys automatically; an older installed
KMS can continue using the legacy boot routes while this migration is prepared.

The Rust backend implements `/authorizeKms` and `/authorizeApp` with the same
registered-root requirement as the other backends. Missing registration denies key
Expand Down
12 changes: 12 additions & 0 deletions dstack/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dstack/crates/dstack-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ serde.workspace = true
serde_json.workspace = true

[dev-dependencies]
dstack-cli-core.workspace = true
tempfile.workspace = true
56 changes: 56 additions & 0 deletions dstack/crates/dstack-auth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,4 +1446,60 @@ mod tests {
.unwrap();
assert!(check_app(&info2, &al).is_allowed);
}

/// An allowlist initialized by `dstackup`, populated with the attested KMS
/// identity + epoch-0 roots, and extended by `dstack deploy` authorizes app
/// key release through `/authorizeApp`.
#[test]
fn dstackup_registered_allowlist_authorizes_apps() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("auth-allowlist.json");
let os_image = "aa".repeat(32);
let kms_id = "11".repeat(20);
let app_id = "22".repeat(20);
let compose_hash = "33".repeat(32);
let ca_pubkey = [0x30u8; 48];
let k256_pubkey = [0x02u8; 33];

dstack_cli_core::config::ensure_allowlist(
&path,
&dstack_cli_core::config::HostConfig {
os_image_hash: os_image.clone(),
..Default::default()
},
)
.unwrap();
dstack_cli_core::config::register_app_in_allowlist(&path, &app_id, &compose_hash).unwrap();

let req = AuthorizationRequest {
operation: Operation::AppGetKey,
boot_info: boot(&app_id, &compose_hash, &os_image),
requested_root_epoch: Some(0),
requested_app_epoch: Some(0),
};
// Before post-bootstrap root-epoch registration, /authorizeApp denies.
let before = authorize(&req, false, &load(&path)).unwrap();
assert!(!before.authorized);
assert_eq!(before.rejection_reason, "root epoch not registered");

// After post-bootstrap root-epoch registration, /authorizeApp authorizes.
dstack_cli_core::config::register_kms_root_epoch_in_allowlist(
&path,
&kms_id,
&ca_pubkey,
&k256_pubkey,
)
.unwrap();
let after = authorize(&req, false, &load(&path)).unwrap();
assert!(after.authorized, "rejected: {}", after.rejection_reason);
assert_eq!(after.current_root_epoch, 0);
assert_eq!(after.latest_root_epoch, 0);
let expected_hash = format!(
"0x{}",
hex::encode(
dstack_types::root_epoch::chain_hashes([(&ca_pubkey[..], &k256_pubkey[..])])[0]
)
);
assert_eq!(after.current_root_epoch_hash, expected_hash);
}
}
2 changes: 2 additions & 0 deletions dstack/crates/dstack-cli-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true

[dependencies]
anyhow.workspace = true
hex = { workspace = true, features = ["alloc"] }
http-client = { workspace = true, features = ["prpc"] }
dstack-vmm-rpc.workspace = true
dstack-types.workspace = true
Expand All @@ -20,4 +21,5 @@ safe-write.workspace = true
rustix = { version = "0.38", features = ["fs"] }

[dev-dependencies]
tempfile.workspace = true
toml.workspace = true
Loading
Loading