Skip to content

Commit 4ce0571

Browse files
h4x3rotabclaude
andcommitted
docs: revamp SDK READMEs and update main documentation
SDK Documentation: - Rewrite all SDK READMEs (Python, JS, Rust, Go) for concise style - Add HTTP API reference section to sdk/README.md - Fix curl API docs (invalid JSON, mark Sign/Verify as unreleased) - Test all SDK code snippets against live dstack.sock Main README: - Add chat.redpill.ai as "Try it now" entry point - Add HTTP API link in SDKs section Security Documentation: - Split security.md into security-model.md and security-best-practices.md - Update AI docs (inference, agents, training) for TEE-agnostic language 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9e2522f commit 4ce0571

15 files changed

Lines changed: 846 additions & 1828 deletions

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ AI providers ask users to trust them with sensitive data. But trust doesn't scal
4040

4141
## Getting Started
4242

43-
**1. Deploy a private LLM:**
43+
**Try it now:** Chat with LLMs running in TEE at [chat.redpill.ai](https://chat.redpill.ai). Click the shield icon to verify attestations from Intel TDX and NVIDIA GPUs.
44+
45+
**Deploy your own:**
4446

4547
```yaml
4648
# docker-compose.yaml
@@ -55,12 +57,6 @@ services:
5557
5658
Deploy to any TDX host with the `dstack-nvidia-0.5.x` base image, or use [Phala Cloud](https://cloud.phala.network) for managed infrastructure.
5759

58-
**2. Verify what's running:**
59-
60-
Every dstack deployment can generate a TDX attestation quote: cryptographic proof of the exact code running inside the confidential VM.
61-
62-
Try it: [dstack-demo.phala.com](https://dstack-demo.phala.com) → Click "Verify" → See the proof on [proof.t16z.com](https://proof.t16z.com)
63-
6460
Want to deploy a self hosted dstack? Check our [full deployment guide →](./docs/deployment.md)
6561

6662
## Architecture
@@ -83,6 +79,8 @@ Your container runs inside a Confidential VM (Intel TDX) with optional GPU isola
8379

8480
## SDKs
8581

82+
Apps communicate with the guest agent via HTTP over `/var/run/dstack.sock`. Use the [HTTP API](./sdk/curl/api.md) directly with curl, or use a language SDK:
83+
8684
| Language | Install | Docs |
8785
|----------|---------|------|
8886
| Python | `pip install dstack-sdk` | [README](./sdk/python/README.md) |

docs/agents.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Running in a TEE ensures these secrets remain protected, and attestation proves
1515

1616
```
1717
┌────────────────────────────────────────────────────────────┐
18-
│ dstack CVM (TDX)
18+
dstack CVM
1919
│ │
2020
│ ┌─────────────────────────────────────────────────────┐ │
2121
│ │ Your Agent │ │
@@ -244,8 +244,8 @@ attestation = requests.get(
244244
params={"nonce": "random-challenge"}
245245
).json()
246246

247-
# Verify TDX quote via proof.t16z.com or programmatically
248-
is_valid = verify_tdx_quote(attestation['quote'])
247+
# Verify attestation quote via proof.t16z.com or programmatically
248+
is_valid = verify_quote(attestation['quote'])
249249

250250
# Check agent code hash matches expected
251251
assert attestation['compose_hash'] == EXPECTED_AGENT_HASH
@@ -257,9 +257,9 @@ assert attestation['compose_hash'] == EXPECTED_AGENT_HASH
257257
|---------|------------|
258258
| API Keys | Encrypted at deploy, decrypted only in TEE |
259259
| Wallet Keys | Derived deterministically, never leave TEE |
260-
| Agent Code | Measured and attested via TDX |
260+
| Agent Code | Measured and attested via TEE |
261261
| Data in Transit | TLS termination inside TEE |
262-
| Execution Proof | TDX quotes for any operation |
262+
| Execution Proof | Attestation quotes for any operation |
263263

264264
## Production Considerations
265265

docs/cvm-boundaries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ dstack uses encrypted environment variables to allow app developers to securely
117117
- CVM performs basic regex validation on values
118118
- Final result is stored as /dstack/.hostshared/.decrypted-env and loaded system-wide via app-compose.service
119119

120-
This file is not measured to RTMRs. But it is highly recommended to add application-specific integrity checks on encrypted environment variables at the application layer. See [security.md](security.md) for more details.
120+
This file is not measured to RTMRs. But it is highly recommended to add application-specific integrity checks on encrypted environment variables at the application layer. See [security-best-practices.md](security-best-practices.md) for more details.
121121

122122
### .user-config
123123
This is an optional application-specific configuration file that applications inside the CVM can access. dstack OS simply stores it at /dstack/user-config without any measurement or additional processing.

docs/inference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Run LLM inference with hardware attestation and cryptographic proof of responses
66

77
```
88
┌─────────────┐ ┌──────────────────────────────────────────────┐
9-
│ Client │ │ dstack CVM (TDX)
9+
│ Client │ │ dstack CVM
1010
│ │ │ ┌─────────────┐ ┌─────────────────┐ │
1111
│ Request ───┼────►│ │ vllm-proxy │──────│ vLLM Backend │ │
1212
│ │ │ │ (attestation│ │ (OpenAI API) │ │
1313
│ ◄──────────┼─────│ │ + signing) │◄─────│ │ │
1414
│ Response │ │ └─────────────┘ └─────────────────┘ │
1515
│ + Signature│ │ │ │
16-
│ + TDX Quote│ │ └── /var/run/dstack.sock │
16+
│ + TEE Quote│ │ └── /var/run/dstack.sock │
1717
└─────────────┘ └──────────────────────────────────────────────┘
1818
```
1919

2020
**vllm-proxy** adds a security layer to vLLM:
21-
- **Hardware attestation**TDX quotes proving execution in secure hardware
21+
- **Hardware attestation**TEE quotes proving execution in secure hardware
2222
- **Response signing** — Every response cryptographically signed (ECDSA + ED25519)
2323
- **GPU attestation** — NVIDIA Confidential Computing verification (when available)
2424

@@ -87,14 +87,14 @@ attestation = requests.get(
8787
params={"nonce": "your-random-nonce"}
8888
).json()
8989

90-
print(f"TDX quote: {attestation['tdx_quote'][:100]}...")
90+
print(f"TEE quote: {attestation['quote'][:100]}...")
9191
print(f"GPU evidence: {attestation.get('gpu_evidence', 'N/A')}")
9292
```
9393

9494
Or paste the attestation into [proof.t16z.com](https://proof.t16z.com) for visual verification.
9595

9696
The attestation binds the signing key to the TEE hardware. Verify:
97-
1. TDX quote is valid (via [proof.t16z.com](https://proof.t16z.com) or dstack verifier)
97+
1. TEE quote is valid (via [proof.t16z.com](https://proof.t16z.com) or dstack verifier)
9898
2. Signing address in quote matches the one that signed responses
9999
3. Response hash matches your received content
100100

docs/onchain-governance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@ Source: [`kms/auth-eth/contracts/`](../kms/auth-eth/contracts/)
186186
## See Also
187187

188188
- [Deployment Guide](./deployment.md) - Setting up dstack infrastructure
189-
- [Security Guide](./security.md) - Security best practices
189+
- [Security Best Practices](./security-best-practices.md)
File renamed without changes.

docs/security-model.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# dstack Security Model
2+
3+
dstack protects your code and data from infrastructure operators. Using TEE hardware isolation, your workloads run in encrypted memory that the host cannot read or modify. You can cryptographically verify that your exact code runs in genuine TEE hardware.
4+
5+
This document helps you evaluate whether dstack's security model fits your needs.
6+
7+
## Trust Boundaries
8+
9+
dstack removes the need to trust infrastructure operators. The cloud provider cannot read your memory, modify your code, or access your secrets. Network attackers cannot intercept your traffic because TLS terminates inside the TEE with keys fully controlled by the TEE (Zero Trust HTTPS). Docker registries cannot serve malicious images because the TEE verifies SHA256 digests before pulling.
10+
11+
The only thing you must trust is **TEE hardware** (currently Intel TDX, with AMD SEV support planned). You trust that the TEE provides genuine memory encryption and that quotes are signed by real hardware. For GPU workloads, you also trust **NVIDIA GPU hardware** and NVIDIA's Remote Attestation Service (NRAS). These are hardware-level trust assumptions.
12+
13+
Everything else is verifiable.
14+
15+
**The dstack OS** is measured during boot and recorded in the attestation quote. You verify it by rebuilding from [meta-dstack](https://github.com/Dstack-TEE/meta-dstack) source and comparing measurements, or by checking that the OS hash is whitelisted in a governance contract you trust.
16+
17+
**The KMS** runs in its own TEE with its own attestation quote. You verify it the same way you verify any dstack workload.
18+
19+
### What dstack Cannot Protect
20+
21+
TEE technology has inherent limitations. Side-channel attacks against TEE hardware are researched actively, and microarchitectural vulnerabilities are discovered periodically. Hardware vendors release TCB updates to address these, so keep your TCB version current.
22+
23+
dstack protects the execution environment, not your application code. Bugs in your application remain exploitable. Secrets that you log or transmit insecurely can still leak. Your code must follow secure development practices.
24+
25+
Infrastructure operators can still deny service. They can shut down your workload, throttle resources, or block network access. If availability matters, plan for redundancy across providers.
26+
27+
## Security Guarantees
28+
29+
### Confidentiality
30+
31+
| Layer | Protection | Mechanism |
32+
|-------|------------|-----------|
33+
| Memory | Encrypted at runtime | TEE hardware encryption |
34+
| Disk | Encrypted at rest | Per-app keys from KMS (AES-256-GCM) |
35+
| Environment | Encrypted in transit | X25519 ECDH + AES-256-GCM |
36+
| Network | Encrypted end-to-end | Zero Trust HTTPS (TLS terminates in TEE) |
37+
38+
### Integrity
39+
40+
| Component | Verification | Measurement |
41+
|-----------|--------------|-------------|
42+
| Hardware | TEE signature | Attestation quote |
43+
| Firmware | Boot measurement | MRTD |
44+
| OS | Boot measurement | RTMR0-2 |
45+
| Application | Runtime measurement | RTMR3 (compose-hash) |
46+
47+
### Isolation
48+
49+
Each application derives unique keys from the KMS based on its identity. Instance-level secrets use the instance ID to create unique disk encryption keys. No keys are shared between different applications.
50+
51+
## GPU Security for AI Workloads
52+
53+
dstack supports NVIDIA H100, H200, and B200 GPUs in confidential compute mode for AI inference and training workloads.
54+
55+
### How It Works
56+
57+
GPUs are passed through via VFIO directly to the TEE-protected CVM. The GPU operates in confidential compute mode, encrypting data during computation. Both the CPU TEE and NVIDIA GPU provide hardware isolation together. If either component fails verification, the security model breaks.
58+
59+
### Dual Attestation
60+
61+
GPU workloads require verification of both hardware components. The CPU TEE provides the quote that verifies CPU and memory isolation. NVIDIA's Remote Attestation Service (NRAS) independently verifies the GPU is genuine and running in confidential mode. Both attestations must pass for complete verification.
62+
63+
### AI Workload Protection
64+
65+
Models and training data stay within the hardware-protected environment. The infrastructure operator cannot access model weights, training data, or inference inputs/outputs. Response integrity is provable through cryptographic signatures generated inside the TEE. Performance overhead is minimal, achieving approximately 99% efficiency compared to native execution.
66+
67+
## Chain of Trust
68+
69+
dstack implements layered verification from hardware to application. Each layer is measured and included in the attestation quote, which TEE hardware cryptographically signs.
70+
71+
```
72+
┌─────────────────────────────────────────────────────────────────┐
73+
│ Attestation Quote (signed by TEE hardware) │
74+
│ ├── Hardware: TEE signature proves genuine hardware │
75+
│ ├── MRTD: Virtual firmware measurement │
76+
│ ├── RTMR0-2: OS kernel and boot parameters │
77+
│ ├── RTMR3: Application (compose-hash) + KMS binding │
78+
│ └── reportData: Your challenge (replay protection) │
79+
├─────────────────────────────────────────────────────────────────┤
80+
│ Event Log (RTMR3 breakdown) │
81+
│ ├── compose-hash: SHA256 of your docker-compose │
82+
│ ├── key-provider: KMS root CA public key hash │
83+
│ └── instance-id: Unique per deployment │
84+
└─────────────────────────────────────────────────────────────────┘
85+
```
86+
87+
**Hardware layer.** The TEE provides the root of trust. The attestation quote is cryptographically signed by TEE hardware, and verification confirms the signature chain. The TCB status shows whether firmware is patched against known vulnerabilities.
88+
89+
**OS layer.** The dstack OS is measured during boot into MRTD and RTMR0-2. MRTD captures the virtual firmware. RTMR0 captures firmware configuration. RTMR1 captures the Linux kernel. RTMR2 captures kernel command-line parameters. You verify integrity by computing expected measurements from meta-dstack source and comparing them to the quote.
90+
91+
**Application layer.** Your application is measured into RTMR3 as the compose-hash, which is the SHA256 hash of your normalized docker-compose configuration. Each image must use SHA256 digest pinning. This proves exactly which container images are running and that no code substitution happened after measurement.
92+
93+
**Key management layer.** The KMS root CA public key hash is recorded in RTMR3 as the key-provider event. This binds your workload to a specific KMS instance. The KMS itself runs in a TEE with its own attestation quote, so you can verify the KMS the same way you verify any workload.
94+
95+
## Verification Checklist
96+
97+
Use this checklist to verify a workload running in a dstack CVM.
98+
99+
**Platform verification:**
100+
- [ ] Attestation quote signature is valid
101+
- [ ] TCB status is up-to-date (no unpatched vulnerabilities)
102+
- [ ] OS measurements match expected values (MRTD, RTMR0-2)
103+
- [ ] OS image hash is whitelisted (if using governance)
104+
105+
**Application verification:**
106+
- [ ] compose-hash matches your docker-compose
107+
- [ ] All images use SHA256 digests (no mutable tags)
108+
- [ ] RTMR3 event log replays correctly
109+
- [ ] reportData contains your challenge (replay protection)
110+
111+
**Key management verification:**
112+
- [ ] key-provider matches expected KMS identity
113+
- [ ] KMS attestation is valid
114+
115+
## Limitations
116+
117+
### Attestation proves identity, not correctness
118+
119+
Attestation proves which code is running, not that the code is bug-free. It proves the environment is isolated, not that your application handles secrets correctly. You still need to audit your application code and follow secure development practices.
120+
121+
### Environment variables need application-layer authentication
122+
123+
Encrypted environment variables prevent the host from reading your secrets. However, the host can replace encrypted values with different ones. Your application should verify authenticity using patterns like LAUNCH_TOKEN. See [security-best-practices.md](security-best-practices.md) for details.
124+
125+
### KMS root key security
126+
127+
All keys derive from the KMS root key, which is protected by TEE isolation. Like all TEE-based systems, a TEE compromise could expose the root key. We are developing MPC-based KMS where the root key is distributed across multiple parties, eliminating this single point of failure.
128+
129+
## Further Reading
130+
131+
For production deployment guidance, see [security-best-practices.md](security-best-practices.md). For smart contract authorization details, see [onchain-governance.md](onchain-governance.md). For technical details about CVM boundaries and APIs, see [cvm-boundaries.md](cvm-boundaries.md).

docs/training.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Running training in a TEE ensures:
1919

2020
```
2121
┌──────────────────────────────────────────────────────────────┐
22-
│ dstack CVM (TDX)
22+
dstack CVM
2323
│ │
2424
│ ┌────────────────────────────────────────────────────────┐ │
2525
│ │ Training Pipeline │ │
@@ -282,8 +282,8 @@ With CC-enabled GPUs:
282282
| Stage | Protection |
283283
|-------|------------|
284284
| Dataset at rest | Encrypted storage |
285-
| Dataset in memory | TDX memory encryption |
286-
| Model weights | TDX + GPU CC memory encryption |
285+
| Dataset in memory | TEE memory encryption |
286+
| Model weights | TEE + GPU CC memory encryption |
287287
| Gradients | Never leave TEE |
288288
| Output model | Attestation-signed |
289289

sdk/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
# SDK
1+
# dstack SDKs
22

3-
This SDK propose for simple the interaction with dstack guest agent. You can also download simulator [here](https://github.com/Leechael/dstack-simulator/releases) or using the [Docker based image](https://hub.docker.com/r/phalanetwork/dstack-simulator) to kick start without real TDX hardware.
3+
Client libraries for interacting with the dstack guest agent from inside a TEE.
4+
5+
## HTTP API
6+
7+
All SDKs communicate with the guest agent via HTTP over a Unix socket (`/var/run/dstack.sock`). See the [HTTP API Reference](curl/api.md) for direct access using curl or any HTTP client.
8+
9+
## SDKs
10+
11+
| Language | Path |
12+
|----------|------|
13+
| [Python](python/) | `sdk/python` |
14+
| [JavaScript/TypeScript](js/) | `sdk/js` |
15+
| [Rust](rust/) | `sdk/rust` |
16+
| [Go](go/) | `sdk/go` |
17+
18+
## Simulator
19+
20+
For local development without TDX hardware, use the simulator:
21+
22+
- [Download releases](https://github.com/Leechael/dstack-simulator/releases)
23+
- [Docker image](https://hub.docker.com/r/phalanetwork/dstack-simulator)

sdk/curl/api.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ curl --unix-socket /var/run/dstack.sock -X POST \
8181
-d '{
8282
"path": "my/key/path",
8383
"purpose": "signing",
84-
"algorithm": "ed25519",
84+
"algorithm": "ed25519"
8585
}'
8686
```
8787

@@ -193,7 +193,7 @@ curl --unix-socket /var/run/dstack.sock -X POST \
193193
**Response:**
194194
Empty response with HTTP 200 status code on success.
195195

196-
### 6. Sign
196+
### 6. Sign (not yet released)
197197

198198
Signs a payload.
199199

@@ -230,7 +230,7 @@ curl --unix-socket /var/run/dstack.sock -X POST \
230230
}
231231
```
232232

233-
### 7. Verify
233+
### 7. Verify (not yet released)
234234

235235
Verifies a signature.
236236

@@ -265,8 +265,6 @@ curl --unix-socket /var/run/dstack.sock -X POST \
265265
}
266266
```
267267

268-
```
269-
270268
## Error Responses
271269

272270
All endpoints may return the following HTTP status codes:
@@ -280,3 +278,4 @@ Error responses will include a JSON body with error details:
280278
{
281279
"error": "Error description"
282280
}
281+
```

0 commit comments

Comments
 (0)