Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions kms/kms.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ mandatory = false
cert_dir = "/etc/kms/certs"
subject_postfix = ".dstack"
admin_token_hash = ""
# Whether trusted RPCs require the KMS to first attest itself to its own
# auth API. Defaults to true (strict). Set to false ONLY when running KMS
# outside a TEE (e.g. local dev/testing) where the local guest agent socket
# is unavailable.
enforce_self_authorization = true

[core.image]
verify = true
Expand Down
10 changes: 10 additions & 0 deletions kms/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ pub(crate) struct KmsConfig {
pub image: ImageConfig,
#[serde(with = "serde_human_bytes")]
pub admin_token_hash: Vec<u8>,
/// Whether trusted RPCs require the KMS to first attest itself to its
/// own auth API. Defaults to `true` (strict). Set `false` only for local
/// dev/testing where the KMS runs outside a TEE and cannot reach a guest
/// agent socket.
#[serde(default = "default_true")]
pub enforce_self_authorization: bool,
}

fn default_true() -> bool {
true
}

impl KmsConfig {
Expand Down
3 changes: 3 additions & 0 deletions kms/src/main_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ struct BootConfig {

impl RpcHandler {
async fn ensure_self_allowed(&self) -> Result<()> {
if !self.state.config.enforce_self_authorization {
return Ok(());
}
Comment thread
kvinwang marked this conversation as resolved.
let boot_info = self
.state
.self_boot_info
Expand Down
3 changes: 3 additions & 0 deletions kms/src/main_service/upgrade_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ pub(crate) fn pad64(hash: [u8; 32]) -> Vec<u8> {
}

pub(crate) async fn ensure_self_kms_allowed(cfg: &KmsConfig) -> Result<()> {
if !cfg.enforce_self_authorization {
return Ok(());
}
let boot_info = local_kms_boot_info(cfg.pccs_url.as_deref())
.await
.context("failed to build local KMS boot info")?;
Expand Down
Loading