You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 4, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/How_to_Protect_AI_Models_in_Cloud_Native_Environments.md
+72-13Lines changed: 72 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,9 @@ To ensure the cloud native environments and AI models are secure protected in us
10
10
11
11
## 1. Architecture Design
12
12
13
-
This design can be divided into three steps logically.
13
+
This design can be divided into four steps logically.
14
14
- A plain AI model is preprocessed before uploading or use in cloud native environment. AI model should be encrypted offline, and the encryption key will be stored in a key database server.
15
+
- Fetch and verify event logs. Event logs are the record of measurements made to PCRs (PCR: Platform Configuration Register) by the Platform Firmware, with some informational events not extended to PCRs. The informational events are used to convey valuable information to an evaluator of the log. Each measurement made, as well as the information events, are recorded in the event logs as individual entries with specified fields. Event logs can assist the attestation/verification process. For more detail, please refer to [TCG_PCClient Spec](https://trustedcomputinggroup.org/wp-content/uploads/TCG_PCClientSpecPlat_TPM_2p0_1p04_pub.pdf).
15
16
- Attestation of the cloud native environment. Attestation is a confidential computing keystone. With attestation, AI models owner can fully assert the trustworthiness of the hardware and software environment AI is running in, regardless of the security posture of the underlying infrastructure provider.
16
17
- AI Model fetching and decryption. Before CNAP can start its AI pipeline streaming inference, a proper AI model has to be downloaded then decrypted.
17
18
@@ -26,15 +27,34 @@ To protect the model and its encryption key, the following preprocessing steps a
26
27
- Upload the encrypted model to Model Server.
27
28
- Register key to Key Broker Service (KBS), and KBS will communicate with Key Management Service (KMS) to store the key in its database.
28
29
29
-
### 1.2 Attestation by using Confidential Cloud-Native Primitives (CCNP)
30
+
### 1.2 Fetch and Verify Event Logs by using Confidential Cloud-Native Primitives (CCNP)
30
31
31
-
[CCNP](https://github.com/intel/confidential-cloud-native-primitives) is to enable Intel Trust Domain Extensions (TDX) or other TEE technologies and simplify the usage of TEE in cloud native environment. It comprises two main components: the services and the SDK, which includes event log, measurement, quote generation and other APIs.
32
+
[CCNP](https://github.com/cc-api/confidential-cloud-native-primitives) is to enable Intel Trust Domain Extensions (TDX) or other TEE technologies and simplify the usage of TEE in cloud native environment. It comprises two main components: the services and the SDK, which includes event logs, measurement, quote generation and other APIs.
32
33
33
34
- Service is designed to hide the complexity of different TEE platforms and provides common interfaces and scalability for cloud native environment.
34
35
35
36
- SDK is to simplify the use of the service interface for development, it communicates to the service and parses the return results from the services.
36
37
37
-
The service supports attestation, measurement fetching and event log collecting of various platforms including Intel TDX, Trusted Platform Modules (TPM) and AMD Secure Encrypted Virtualization-Secure Nested Paging (SEV-SNP) (will be supported soon).
38
+
The service supports attestation, measurement fetching and event logs collecting of various platforms including Intel TDX, Trusted Platform Modules (TPM) and AMD Secure Encrypted Virtualization-Secure Nested Paging (SEV-SNP) (will be supported soon).
39
+
40
+
CCNP is a good choice to fetch these evidences including measurements and event logs, which hides the complexity of the underlying platforms and increase the usability of the APIs. Here's the sample code using CCNP:
41
+
42
+
```Python
43
+
from ccnp import Eventlog
44
+
event_logs = Eventlog.get_platform_eventlog()
45
+
```
46
+
47
+
To verify that the event logs have not been tampered with, we can compare the measurement replayed from event logs with the IMR (Integrated Measurement Register) values fetched using CCNP.
48
+
Here's the sample code using CCNP to fetch IMR values (use Intel TDX RTMR as example):
CCNP API detail documentation can be found [here](https://intel.github.io/confidential-cloud-native-primitives/).
56
+
57
+
### 1.3 Attestation by using Confidential Cloud-Native Primitives (CCNP)
38
58
39
59
To get the key to decrypt the model, we need provide the quote of TEE for attestation, CCNP is a good choice to get the quote and it hides the complexity and is easy to use, sample code from CCNP:
40
60
@@ -43,13 +63,12 @@ from ccnp import Quote
43
63
quote=Quote.get_quote()
44
64
```
45
65
46
-
CCNP API detail documentation can be found [here](https://intel.github.io/confidential-cloud-native-primitives/).
47
-
48
-
### 1.3 AI Model Decryption
66
+
### 1.4 AI Model Decryption
49
67
50
68
CNAP project’s Inference Service flow of getting AI model should be updated to support TEE environment since the AI model has been encrypted:
51
69
52
70
- Deploy CCNP as a [DaemonSet](https://intel.github.io/confidential-cloud-native-primitives/_rst/service.quote.html#deploy-as-daemonset-in-kubernetes), it will detect the TEE environment.
71
+
- Fetch and verify event logs.
53
72
- Get the quote and request the key from KBS.
54
73
- Download the encrypted AI model from Model Server.
55
74
- Decrypt AI model and load the model in memory to start AI streaming inference.
@@ -60,7 +79,7 @@ Current Cloud-Native AI Pipeline (CNAP) project already implements the new desig
60
79
61
80
To protect AI model, the first thing is to generate a key for model encryption, encrypt the model and register the key to KBS. Then KBS will submit further request to store the key to KMS.
62
81
63
-
To fetch and decrypt the model, the runtime environment should be verified by attestation. A key broker client should get a quote and send the quote to KBS to verify that it is running on an authentic TEE platform. Upon successful attestation, KBS will then respond with a wrapped key for AI model's decryption later.
82
+
To fetch and decrypt the model, the runtime environment should be verified by event logs and attestation. A key broker client should get a quote and send the quote to KBS to verify that it is running on an authentic TEE platform. Upon successful attestation, KBS will then respond with a wrapped key for AI model's decryption later.
64
83
65
84
### 2.1 AI Model Encryption
66
85
@@ -159,6 +178,7 @@ An sample working flow of a simple KBS implementation:
159
178
160
179
For a key broker client, here is an example working flow of key broker client to get a key from KBS:
161
180
181
+
- Get and replay all event logs, and verify by the measurement register.
162
182
- Generate 2048 bit RSA key pair (a public key and a private key).
163
183
- Encode the public key to base64 for transferring (user_data).
164
184
- Get quote in the TEE with the hash of the public key for measurement (quote).
@@ -192,7 +212,45 @@ req_body = {
192
212
}
193
213
```
194
214
195
-
### 2.5 Attestation
215
+
### 2.5 Fetch and Verify Event Logs
216
+
217
+
CCNP provides an easy way to fetch and verify event logs in TEE. After fetching event logs, we can compare the measurement replayed from event logs with the IMR (Integrated Measurement Register) values fetched using CCNP to verify that event logs have not been tampered with.
218
+
219
+
We can fetch, replay and verify event logs before attestation, the sample code:
220
+
221
+
```Python
222
+
import logging
223
+
224
+
from ccnp import Eventlog, Measurement, MeasurementType
225
+
226
+
LOG= logging.getLogger(__name__)
227
+
IMR_VERIFY_COUNT=3
228
+
229
+
# Fetch event logs using CCNP and replay.
230
+
event_logs = Eventlog.get_platform_eventlog()
231
+
measurement_dict = replay(event_logs)
232
+
233
+
# Fetch IMR measurement (use Intel TDX RTMR as example) and verify with replayed value.
LOG.info("IMR[%d] passed the verification.", index)
246
+
else:
247
+
LOG.error("IMR[%d] did not pass the verification.", index)
248
+
raiseRuntimeError("Event logs verify failed.")
249
+
250
+
LOG.info("Event logs verify successfully.")
251
+
```
252
+
253
+
### 2.6 Attestation
196
254
197
255
CCNP provides an easy way to get the quote for attestation in TEE. Before getting the quote, a RSA key pair need to be generated for wrapping purpose and the public key will be measured as the user data input to the quote fetching process.
As organizations move more of their AI workloads to the cloud, AI models security, and protection has become more important. Confidential computing provides a set of technologies designed to protect data in use, such as AI models currently being processed by the machine, or currently in memory.
254
-
This document describes a common architecture to “design and run” a native AI Model into confidential computing environments. (1) AI Model preprocess (2) Attestation of the cloud native environment (3) AI Model fetching and decryption.
255
-
Intel’s TDX technology can provide a TEE running environment, and CCNP can simply the attestation of confidential native environment, last but not least, a sample KBS is introduced to help customer to connect with its own or vendor-independent attestation service (for example, Intel Trust Authority).
312
+
This document describes a common architecture to “design and run” a native AI Model into confidential computing environments. (1) AI Model preprocess (2) Fetch and verify event logs (3) Attestation of the cloud native environment (4) AI Model fetching and decryption.
313
+
Intel’s TDX technology can provide a TEE running environment, and CCNP can simplify the event logs, measurement fetching and attestation of confidential native environment, last but not least, a sample KBS is introduced to help customer to connect with its own or vendor-independent attestation service (for example, Intel Trust Authority).
256
314
257
315
# References
258
316
259
317
1. Model Provider: https://github.com/intel/cloud-native-ai-pipeline/blob/main/cnap/core/modelprovider.py
0 commit comments