Skip to content

Commit 0e325c1

Browse files
committed
feat(kms): make self-authorization enforcement configurable
Add core.enforce_self_authorization (default true) so trusted RPCs and the onboard bootstrap path can skip the local self-attestation step when KMS is intentionally run outside a TEE — e.g. local dev/testing where there is no /var/run/dstack(.sock) to dial. Default stays strict (true) so production deployments are unchanged. When set to false, both RpcHandler::ensure_self_allowed and the free ensure_self_kms_allowed return early without attempting to attest. Why: the strict-by-default check (introduced in 06d89a2) makes any non-TEE host KMS instance unable to serve a single request because the OnceCell-cached self_boot_info can never initialize. This blocks local CVM testing setups that previously relied on an unauthenticated host KMS process.
1 parent a673ab7 commit 0e325c1

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

kms/kms.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ mandatory = false
2626
cert_dir = "/etc/kms/certs"
2727
subject_postfix = ".dstack"
2828
admin_token_hash = ""
29+
# Whether trusted RPCs require the KMS to first attest itself to its own
30+
# auth API. Defaults to true (strict). Set to false ONLY when running KMS
31+
# outside a TEE (e.g. local dev/testing) where the local guest agent socket
32+
# is unavailable.
33+
enforce_self_authorization = true
2934

3035
[core.image]
3136
verify = true

kms/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ pub(crate) struct KmsConfig {
4040
pub image: ImageConfig,
4141
#[serde(with = "serde_human_bytes")]
4242
pub admin_token_hash: Vec<u8>,
43+
/// Whether trusted RPCs require the KMS to first attest itself to its
44+
/// own auth API. Defaults to `true` (strict). Set `false` only for local
45+
/// dev/testing where the KMS runs outside a TEE and cannot reach a guest
46+
/// agent socket.
47+
#[serde(default = "default_true")]
48+
pub enforce_self_authorization: bool,
49+
}
50+
51+
fn default_true() -> bool {
52+
true
4353
}
4454

4555
impl KmsConfig {

kms/src/main_service.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ struct BootConfig {
102102

103103
impl RpcHandler {
104104
async fn ensure_self_allowed(&self) -> Result<()> {
105+
if !self.state.config.enforce_self_authorization {
106+
return Ok(());
107+
}
105108
let boot_info = self
106109
.state
107110
.self_boot_info

kms/src/main_service/upgrade_authority.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ pub(crate) fn pad64(hash: [u8; 32]) -> Vec<u8> {
206206
}
207207

208208
pub(crate) async fn ensure_self_kms_allowed(cfg: &KmsConfig) -> Result<()> {
209+
if !cfg.enforce_self_authorization {
210+
return Ok(());
211+
}
209212
let boot_info = local_kms_boot_info(cfg.pccs_url.as_deref())
210213
.await
211214
.context("failed to build local KMS boot info")?;

0 commit comments

Comments
 (0)