feat(kms): make self-authorization enforcement configurable#651
Merged
feat(kms): make self-authorization enforcement configurable#651
Conversation
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.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configuration switch to let dstack-kms run in non-TEE environments by optionally skipping the “self-authorization” (self-attestation + auth-api check) gate that currently blocks all trusted RPCs when the guest-agent socket is unavailable.
Changes:
- Introduces
core.enforce_self_authorizationinKmsConfigwith a default oftrue. - Short-circuits self-authorization checks in both the main RPC handler and upgrade/onboarding authority path when the flag is
false. - Documents the option in the default
kms.toml.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
kms/src/main_service/upgrade_authority.rs |
Skips ensure_self_kms_allowed self-authorization when config disables enforcement. |
kms/src/main_service.rs |
Skips per-request self-authorization gate for trusted RPCs when enforcement is disabled. |
kms/src/config.rs |
Adds KmsConfig::enforce_self_authorization with a default-true serde default. |
kms/kms.toml |
Documents enforce_self_authorization = true and warns it’s for non-TEE dev/testing only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/Dstack-TEE/dstack/sessions/45dd268c-01c8-4e86-bd8f-978cbb70dff7 Co-authored-by: kvinwang <6442159+kvinwang@users.noreply.github.com>
Contributor
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Summary
Add
core.enforce_self_authorization(defaulttrue) so KMS can opt out of the self-attestation step on trusted RPCs when run intentionally outside a TEE.Motivation
Commit 06d89a2 ("kms: enforce self authorization on trusted RPCs") makes every trusted RPC first call `local_kms_boot_info` -> `app_attest`, which dials `/var/run/dstack(.sock)` (or its newer path) for a TDX quote. When KMS runs on a non-TEE host (local dev / integration testing setups), that socket does not exist, so the `OnceCell`-cached `self_boot_info` can never initialize and every trusted request returns 400 with `KMS self authorization failed: ...: No such file or directory (os error 2)`.
Existing host-mode setups that relied on this only kept working because their long-lived KMS process initialized the cache once when a socket happened to be present and then held it indefinitely. Any restart breaks them.
Changes
Test plan