Repository navigation
feat(gateway): audit CVM registration and state-changing admin RPCs - #1588
Merged
Merged
Conversation
This was referenced Nov 15, 2026
The gateway logged some admin changes as ad-hoc lines without the caller, and others, such as exit, renew_cert, set_caa, remove_cvm or the port policy RPCs, not at all. Log each state-changing admin RPC to dstack_gateway::audit with its operation, a subject (ids, domains and flags; never tokens or keys), the caller's remote and, if refused, the error. Log RegisterCvm the same way once the CVM's app and instance ids are known, with the WireGuard address it was given. The ad-hoc lines these replace go. Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
Record a forced exit before the process terminates, include the generated id of a new DNS credential, name ZT domains by their normalized form, and say which step failed when create_dns_credential or import_cert fails after a partial effect. Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
feat/gateway-audit-logs
branch
from
November 15, 2026 16:00
8c3246f to
9656367
Compare
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 gateway logged some admin changes as ad-hoc
infolines without the caller, and others not at all (exit,renew_cert,set_caa,reload_cert,rotate_acme_credentials,remove_*, the port policy andset_instance_readyRPCs, ...). CVM registration was not logged with its identity either.dstack_gateway::audit:infoon success,warnwitherrorif refused, withoperation,remote(the caller's address) and a subject naming what it acted on: ids, domains and flags, never DNS tokens, certificate keys or other secrets.RegisterCvmlogscvm registered(withapp_id,instance_id, the assigned WireGuardclient_ip,remote) orcvm registration refused(witherror), once the CVM's app and instance ids are known from its app info or attestation.remove_cvmactually removed) stay.Read-only admin RPCs are not audited; every prpc request's method and caller are already in the request span. Remote addresses behind a TCP proxy come with #1582.
Most of the diff is re-indentation from wrapping each handler body (best viewed with whitespace hidden).
Testing
cargo test -p dstack-gateway --all-featurespasses (340), as do clippy with the CI flags andcargo fmt --check. With a temporary test calling the handlers on a test gateway state with a remote of198.51.100.7:4242:RegisterCvmis not exercised by these tests; it was verified on TDX (below).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.dstack_gateway::auditwith the caller's remote:set_node_statusandset_tombstone_gc_configasadmin: …, and a bad status, an unknown ZT domain and an unknown instance asadmin refused: …with the error;Statuswas not audited.cvm registeredwith itsapp_id,instance_id,client_ipandremote.