Skip to content

backport(v0.5.x): authenticate KMS before sending launch tickets - #1689

Closed
kvinwang wants to merge 2 commits into
release/v0.5.xfrom
backport/v0.5.x-kms-pin-launch-ticket
Closed

kvinwang wants to merge 2 commits into
release/v0.5.xfrom
backport/v0.5.x-kms-pin-launch-ticket

Conversation

@kvinwang

@kvinwang kvinwang commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Backport of #1656 to v0.5.x, with the handshake issuer pin from #1577 (38eb367) that it builds on.

Problem

Since #1579, 0.5.x guests send the launch ticket in GetAppKey and SignCert, but the KMS is authenticated only after the request is sent:

  • On first contact, dstack-util trusts the CA that the KMS itself returns from the unauthenticated GetTempCaCert. It checks the compose key_provider_id only after GetAppKey returns.
  • The kms:rpc usage check runs in cert_validator, which runs on the response. A server holding any certificate under the KMS root (e.g. an app's app:custom cert) completes the handshake and receives the ticket.

Fix

  • ra-rpc: RaClientConfig::tls_pinned_issuer requires, during the handshake, a non-CA leaf within its validity, with the pinned special usage, signed directly by the pinned key. It requires an https URL and disables redirects.
  • dstack-util: pin the KMS to the CA this boot already established when there is one. Otherwise pin it to the compose key_provider_id when that is non-empty. With neither, the behaviour is unchanged.
  • cert-client: pin the runtime KMS client (SignCert, historical GetAppKey) to the CA's key.

The KMS signs its kms:rpc certificate directly with the root CA key (kms/src/onboard_service.rs), so existing KMS deployments pass the pin.

Verification

  • cargo test --locked -p ra-rpc -p cert-client -p dstack-util passes. It includes the ported ra-rpc/tests/issuer_pinning.rs: wrong issuer, wrong usage, CA, and expired leaves never receive the request.
  • cargo clippy -D warnings on cert-client, dstack-util, dstack-guest-agent and ra-rpc. ra-rpc is run with -A clippy::items_after_test_module for a lint already failing on this branch in rocket_helper.rs.
  • Not tested against a live KMS or on a CVM image.

@kvinwang
kvinwang marked this pull request as draft December 1, 2026 02:53
@kvinwang kvinwang closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant