-
Notifications
You must be signed in to change notification settings - Fork 90
feat: cache NVIDIA GPU attestation collateral #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,470
−23
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
65e7f1f
feat: add NVIDIA attestation collateral cache
kvinwang 6d369e4
Merge branch 'hapi-gpu-verify' into hapi-gpu-ocsp-cache
kvinwang 092ecba
chore: trigger CI
kvinwang a143e91
test(gpu): avoid hard-coded attestation nonces
kvinwang b147e09
fix(yocto): mark nvattest patch upstream status
kvinwang e2aa333
feat(gpu): refresh OCSP cache before expiry
kvinwang d9a01b3
feat(gpu-attest-proxy): add background refresh and stale-RIM fallback
kvinwang 22e28b4
refactor: rename gpu-attest-proxy crate to nvidia-attest-proxy
kvinwang 3afdc16
Merge remote-tracking branch 'origin/master' into hapi-gpu-ocsp-cache
kvinwang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # SPDX-FileCopyrightText: © 2026 Phala Network <dstack@phala.network> | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| [package] | ||
| name = "dstack-nvidia-attest-proxy" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
|
|
||
| [dependencies] | ||
| anyhow.workspace = true | ||
| base64.workspace = true | ||
| bytes.workspace = true | ||
| futures.workspace = true | ||
| chrono.workspace = true | ||
| clap = { workspace = true, features = ["env"] } | ||
| dashmap.workspace = true | ||
| hex = { workspace = true, features = ["alloc"] } | ||
| http.workspace = true | ||
| http-body-util.workspace = true | ||
| humantime.workspace = true | ||
| hyper = { workspace = true, features = ["server"] } | ||
| hyper-util = { workspace = true, features = ["tokio"] } | ||
| reqwest.workspace = true | ||
| serde.workspace = true | ||
| serde_json.workspace = true | ||
| sha2.workspace = true | ||
| tokio = { workspace = true, features = ["full"] } | ||
| tracing.workspace = true | ||
| tracing-subscriber.workspace = true | ||
| url.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| tempfile.workspace = true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # NVIDIA GPU Attestation Proxy | ||
|
|
||
| `dstack-nvidia-attest-proxy` is a persistent, PCCS-like cache for the two NVIDIA | ||
| services used by local GPU attestation: | ||
|
|
||
| - `POST /ocsp` caches DER OCSP responses by the request's certificate IDs. The | ||
| per-request OCSP nonce is deliberately excluded from the key. | ||
| - `GET /v1/rim/<id>` caches version-addressed NVIDIA RIM documents. | ||
| - `GET /healthz` reports process health. | ||
| - `GET /info` reports fresh/stale entry counts per cache kind. | ||
|
|
||
| The proxy never signs or rewrites collateral. `nvattest` in the CVM still | ||
| verifies NVIDIA's certificate chains, OCSP signatures, response validity | ||
| window, RIM signatures, measurements, and the fresh GPU evidence nonce. Cache | ||
| entries are persisted so a warm cache survives both proxy and VM restarts. | ||
|
|
||
| ## Run | ||
|
|
||
| ```bash | ||
| cargo build --release -p dstack-nvidia-attest-proxy | ||
| sudo install -m 0755 target/release/dstack-nvidia-attest-proxy /usr/local/bin/ | ||
| sudo install -d -m 0750 /var/cache/dstack/nvidia-attest-proxy | ||
|
|
||
| sudo /usr/local/bin/dstack-nvidia-attest-proxy \ | ||
| --listen 0.0.0.0:8090 \ | ||
| --cache-dir /var/cache/dstack/nvidia-attest-proxy | ||
| ``` | ||
|
|
||
| All options have environment-variable equivalents; see `--help`. In | ||
| particular, `NV_ATTESTATION_SERVICE_KEY` supplies an optional NVIDIA bearer | ||
| token without placing it on the command line. | ||
|
|
||
| Configure the VMM with a URL reachable during early guest boot: | ||
|
|
||
| ```toml | ||
| [cvm] | ||
| nvidia_attestation_proxy_url = "http://10.0.2.2:8090" | ||
| ``` | ||
|
|
||
| For QEMU user-mode networking, `10.0.2.2` is normally the host address. Other | ||
| networking modes should use the corresponding host or fleet service address. | ||
|
|
||
| ## Cache behavior | ||
|
|
||
| On a cold miss the original request is forwarded to NVIDIA. A successful OCSP | ||
| response is cached no later than its signed `nextUpdate` and no longer than | ||
| `--ocsp-max-ttl` (24 hours by default). Responses without `nextUpdate` use one | ||
| hour from `thisUpdate`, matching the pinned NVIDIA SDK. RIM documents default | ||
| to a 30-day TTL. | ||
|
|
||
| Two mechanisms keep entries warm, and they compose: a background sweep (every | ||
| `--refresh-interval`, 10 minutes by default) renews entries that have | ||
| consumed half their lifetime, so a warm cache rides through an NVIDIA outage | ||
| with close to a full validity window instead of only the remainder; entries | ||
| past their usefulness are dropped, not retried. As a synchronous fallback, an | ||
| OCSP response with less than `--ocsp-refresh-before` validity remaining | ||
| (five minutes by default) is refreshed in-line on the next request before it | ||
| is served — concurrent refreshes for the same entry are coalesced. If an | ||
| in-line refresh fails, the proxy keeps serving the old response only until | ||
| its existing signed expiry; it never extends or serves an expired one. | ||
|
|
||
| Expired OCSP entries are never served. Therefore a warm cache removes the | ||
| NVIDIA service from the boot path only for the signed validity period; it does | ||
| not turn revocation checking into an indefinite fail-open. RIM documents are | ||
| signed and version-addressed, so an expired RIM entry — unlike OCSP — may | ||
| still be served for up to `--rim-max-stale` (7 days by default) when the | ||
| upstream is unreachable or failing; the guest verifies its signature either | ||
| way. Response headers expose `X-Dstack-Cache: HIT|MISS|REFRESH|STALE`, `Age`, | ||
| and `X-Dstack-Cache-Expires` for operations. | ||
| Each cache kind is capped at 10,000 entries by default; the oldest entry is | ||
| evicted when the limit is reached. Use `--max-cache-entries-per-kind` to tune | ||
| the bound for a deployment. | ||
|
|
||
| Because a cached response contains the nonce from the request that populated | ||
| the cache, `nvattest` reports `x-nvidia-cert-ocsp-nonce-matches = false` on a | ||
| hit. When the proxy URL is configured, dstack selects NVIDIA's packaged | ||
| `allow_trust_outpost_ocsp.rego` policy. This relaxes only the OCSP nonce check; | ||
| the GPU attestation report's independent nonce remains required by dstack. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.