Repository navigation
feat(kms): audit refused key requests and env public key requests - #1583
Merged
Merged
Conversation
Only released keys were audited, so a request the KMS refused showed up as a bare rpc error without the app that made it. Log a refused GetAppKey, SignCert or GetKmsKey to dstack_kms::audit with the caller's app and instance IDs, remote and error, once its attestation identifies it; refusals before that have no app to name. Also audit every GetAppEnvEncryptPubKey and GetSealedEnvPubKey request with its app ID, which is checked for length first so a bogus one is not logged. Signed-off-by: Kevin Wang <wy721@qq.com>
This was referenced Nov 15, 2026
kvinwang
added a commit
that referenced
this pull request
Nov 16, 2026
tc-kms-kms-007 runs a second candidate KMS with the fixture's keys, the public listener enabled and proxy_protocol on by default but off on the admin listener. It checks which listener serves which RPC, that the PROXY source is the remote in request and audit lines (#1583), and that the old listener locations are refused. Signed-off-by: Kevin Wang <wy721@qq.com>
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.
The KMS audited only released keys (
key releaseondstack_kms::audit). A refused request appeared as a barerpc errorline without the app that made it, and the env public key RPCs were not audited at all.GetAppKey,SignCertandGetKmsKey(RPC and admin): a refusal is logged askey release deniedwithlistener,operation,app_id,instance_id,remoteanderror, once the caller's attestation identifies it. Refusals before that (no attestation, an undecodable request, this KMS failing its own self check) have no app to name and keep only the rpc error log.GetAppEnvEncryptPubKeyandGetSealedEnvPubKey: every request is logged, asenv public key servedorenv public key refused(witherror), withoperation,app_idandremote. The app ID length is now checked before the KMS self check, so a malformed one is rejected, unlogged, withapp_id must be 20 byteseven when the self check would also fail.Refactor:
ensure_app_boot_allowedis inlined andensure_kms_allowedtakes the boot info, so the caller holds it for the log. Behavior is otherwise unchanged; the diff is mostly re-indentation (best viewed with whitespace hidden).Testing
cargo test -p dstack-kms --all-featurespasses (95 tests), as do clippy with the CI flags andcargo fmt --check. With a log subscriber temporarily added to the existing denial tests, each refusal path emits the new line, for example:remote=Nonebecause the unit tests call the handler directly; over a real listener it carries the client address.Verified on TDX
Run on the tdxlab TDX host with real TDX CVMs (guest OS dstack 0.6.0), from one local build of #1580, #1582, #1585 and #1587 merged with #1583 and #1588: the official 0.6.3 KMS and gateway images with these binaries (and the gateway's new
entrypoint.sh). The KMS ran in a CVM with a local key provider and a webhook auth backend (allow all but one app; this KMS's root epoch 0 registered); haproxy withsend-proxy-v2fronted the guest listeners of the KMS and the gateway.App not allowed: Authorization denied: denied by the test webhook; the KMS loggedkey release deniedwith itsapp_id,instance_id,remoteand the error.GetAppKeyandSignCertloggedkey releaseas before;vmm-cli's env encryption loggedenv public key servedwith the app id.