|
| 1 | +# RFC#01929: Remote Attestation via TLS |
| 2 | + |
| 3 | +## Objective |
| 4 | + |
| 5 | +Remotely attest applications in Trusted Execution Environments (TEEs) over the |
| 6 | +TLS protocol. |
| 7 | + |
| 8 | +## Background |
| 9 | + |
| 10 | +A lot of existing applications that would benefit from the remote attestation |
| 11 | +use **TLS protocol** to create secure channels with their clients. But |
| 12 | +integrating the remote attestation might bring up unnecessary complications in a |
| 13 | +form of completely rewriting the application connection logic. |
| 14 | + |
| 15 | +Thus, instead of refactoring existing applications and implementing a new |
| 16 | +protocol, we propose to integrate remote attestation into TLS by |
| 17 | +cryptographically binding **TLS sessions** to the TEE platform. |
| 18 | + |
| 19 | +## Overview |
| 20 | + |
| 21 | +In order to allow applications to use TLS for remote attestation, we propose to |
| 22 | +cryptographically bind assertions to a TLS session, by deriving |
| 23 | +[Exported Keying Material](https://tools.ietf.org/html/rfc5705) from an already |
| 24 | +established TLS session and producing an assertion based on it, e.g. signing it |
| 25 | +with a TEE platform key. |
| 26 | + |
| 27 | +Exported Keying Material is a **pseudo-random string** that may be uniquely |
| 28 | +derived for an individual TLS session. It is derived from the TLS session master |
| 29 | +secret, and thus can be derived by both participants of the TLS session (and no |
| 30 | +other party if [Perfect Forward Secrecy](#parameters) is guaranteed). Exported |
| 31 | +Keying Material can be derived at the application level once the TLS session has |
| 32 | +been established. |
| 33 | + |
| 34 | +We propose to perform remote attestation at the application level (on top of an |
| 35 | +already established and verified TLS session) by deriving Exported Keying |
| 36 | +Material and putting it into the TEE report request as custom data (e.g. |
| 37 | +`REPORT_DATA` field in an |
| 38 | +[SEV-SNP report](https://www.amd.com/system/files/TechDocs/56860.pdf#page=39)). |
| 39 | +This assures that Exported Keying Material is signed by the TEE platform. By |
| 40 | +sending the TEE report over the TLS session, we cryptographically bind the |
| 41 | +session to the TEE platform. |
| 42 | + |
| 43 | +## Attestation |
| 44 | + |
| 45 | +Since Exported Keying Material is derived from the TLS master secret, that is |
| 46 | +shared by both participants of the TLS session, this scheme supports |
| 47 | +**bi-directional remote attestation**. Which means that both client and server |
| 48 | +can run inside the TEE environment and remotely attest each other. Remote |
| 49 | +attestation is performed by checking that: |
| 50 | + |
| 51 | +- TEE reports were generated by valid TEE platform |
| 52 | +- TEE reports contain correct Exported Keying Material derived from this |
| 53 | + particular TLS session |
| 54 | + |
| 55 | +It’s also important to note that this scheme can work with any combination of |
| 56 | +client and server being in a TEE or not (i.e. also supports **unidirectional |
| 57 | +remote attestation**). |
| 58 | + |
| 59 | +### Attestation Workflow |
| 60 | + |
| 61 | +This section presents a high-level attestation workflow overview. The workflow |
| 62 | +of the remote attestation involves 3 interacting entities: |
| 63 | + |
| 64 | +- **Server** |
| 65 | + - Server application that processes requests from TLS clients |
| 66 | + - Can run inside the TEE environment |
| 67 | +- **Client** |
| 68 | + - Client application that connects to applications using TLS |
| 69 | + - Can run inside the TEE environment |
| 70 | +- **Provider** |
| 71 | + - TEE platform provider that can confirm authenticity of TEE platform keys |
| 72 | + - It’s important to note that the Provider is an external server (i.e. belongs |
| 73 | + to AMD) |
| 74 | + |
| 75 | +It is assumed that prior to the attestation workflow both **Server** and |
| 76 | +**Client** remotely attest their TEE platform keys with the **Provider**. |
| 77 | +**Provider** sends back signatures rooted in some well-known root key (i.e. AMD |
| 78 | +root key), thus confirming the authenticity of TEE platform keys. |
| 79 | + |
| 80 | +Another important note is that the current version of the attestation protocol |
| 81 | +prohibits |
| 82 | +[TLS session resumption](https://tools.ietf.org/html/rfc8446#section-2.2), |
| 83 | +because the attestation takes place on the application level and it would need |
| 84 | +to be redone once the TLS session is resumed. |
| 85 | + |
| 86 | +#### Token Derivation |
| 87 | + |
| 88 | +Exported Keying Material is derived using |
| 89 | +[HKDF](https://tools.ietf.org/html/rfc8446#section-7.5) from the TLS session |
| 90 | +master secret and a set of parameters: |
| 91 | + |
| 92 | +- _Label_ |
| 93 | + - Label is required to disambiguate different applications that use the same |
| 94 | + Exported Keying Material mechanism |
| 95 | +- _Context_ |
| 96 | + - Allows the application to mix its own data the pseudo-randomly generated |
| 97 | + Exported Keying Material |
| 98 | +- _Length_ |
| 99 | + - Bit length of the generated value |
| 100 | + |
| 101 | +It’s important to note that with a fixed set of parameters Exported Keying |
| 102 | +Material value for a given TLS session stays the same - i.e. it’s a |
| 103 | +deterministic algorithm. Thus if both client and server negotiate corresponding |
| 104 | +parameters (or they are constant), they can derive equal Exported Keying |
| 105 | +Material values. |
| 106 | + |
| 107 | +Prior to being used Exported Keying Material must be prefixed with the purpose |
| 108 | +string `TLSAttestationV1`. This purpose string is used to disambiguate the |
| 109 | +proper use of the Exported Keying Material, i.e. helps mitigate confusion where |
| 110 | +Exported Keying Material that is generated for one purpose is misused for |
| 111 | +another. |
| 112 | + |
| 113 | +Exported Keying Material that was derived with a specific set of parameters and |
| 114 | +prefixed with the purpose string will be called a **Token** throughout this |
| 115 | +document. Such Token is derived separately with a different set of parameters |
| 116 | +for any given [assertion](#assertions) type. |
| 117 | + |
| 118 | +##### Parameters |
| 119 | + |
| 120 | +Because Token derivation involves a TLS session master secret, TLS server should |
| 121 | +guarantee |
| 122 | +[Perfect Forward Secrecy](https://link.springer.com/content/pdf/10.1007/3-540-46885-4_5.pdf#page=7), |
| 123 | +which is defined as follows: |
| 124 | + |
| 125 | +| TLS master key will not be compromised even if long-term secrets used in its exchange are compromised | |
| 126 | +| ----------------------------------------------------------------------------------------------------- | |
| 127 | + |
| 128 | +This means that if Token parameters are leaked, an attacker would still need the |
| 129 | +TLS session master secret, so they won’t be able to reconstruct the Token. |
| 130 | + |
| 131 | +In order to guarantee _Perfect Forward Secrecy_ the server needs to |
| 132 | +[[RFC8446](https://tools.ietf.org/html/rfc8446#section-2.2)]: |
| 133 | + |
| 134 | +- Use at least [TLS 1.3](https://tools.ietf.org/html/rfc8446) |
| 135 | +- Use one of the following |
| 136 | + [`supported_groups`](https://tools.ietf.org/html/rfc8446#section-4.2.7) for |
| 137 | + key exchange: |
| 138 | + - [Ephemeral Diffie-Hellman (DHE)](https://tools.ietf.org/html/rfc8446#section-7.4.1) |
| 139 | + - [Ephemeral Elliptic Curve Diffie-Hellman (ECDHE)](https://tools.ietf.org/html/rfc8446#section-7.4.2) |
| 140 | + |
| 141 | +###### Label |
| 142 | + |
| 143 | +The **Label** value is needed to distinguish between application level protocols |
| 144 | +that rely on Exported Keying Material. Currently we are using the following |
| 145 | +Label values: |
| 146 | + |
| 147 | +- `EXPERIMENTAL Google Confidential Computing Client Attestation 1.0` |
| 148 | +- `EXPERIMENTAL Google Confidential Computing Server Attestation 1.0` |
| 149 | + |
| 150 | +The main parts of the Label value include: |
| 151 | + |
| 152 | +- `EXPERIMENTAL` prefix |
| 153 | + - Required by [RFC5705](https://tools.ietf.org/html/rfc5705#section-4) to |
| 154 | + avoid possible collisions with existing |
| 155 | + [IANA](https://tools.ietf.org/html/rfc5226)-registered labels |
| 156 | +- `Client`/`Server` |
| 157 | + - Separate Label values for clients and servers are necessary to prevent |
| 158 | + ambiguity and confusion about Label usage |
| 159 | +- Version |
| 160 | + - Necessary to allow protocol upgrades in the future |
| 161 | + |
| 162 | +##### Context |
| 163 | + |
| 164 | +**Context** is a parameter used to derive separate Tokens for different |
| 165 | +[assertion](#assertions) types provided by the firmware. Context value is equal |
| 166 | +to the assertion type, for which a Token is derived. |
| 167 | + |
| 168 | +##### Length |
| 169 | + |
| 170 | +Currently the Exported Keying Material **Length** is set to `16` bytes, similar |
| 171 | +to the Security Strength for _AES-128_ as defined by |
| 172 | +[NIST](https://www.keylength.com/en/4/). |
| 173 | + |
| 174 | +#### Assertions |
| 175 | + |
| 176 | +As defined by the |
| 177 | +[Enclave Key Exchange Protocol (EKEP)](https://asylo.dev/docs/concepts/ekep.html#assertion): |
| 178 | + |
| 179 | +| An assertion is a cryptographically verifiable statement of an identity; an identity corresponding to a given assertion is said to be asserted by that assertion | |
| 180 | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 181 | + |
| 182 | +The protocol supports multiple assertion types (e.g. Intel SGX ECDSA, AMD |
| 183 | +SEV-SNP, public key), each having a type uniquely identified by a string. |
| 184 | + |
| 185 | +#### Initial Handshake |
| 186 | + |
| 187 | +Since applications can run on various platforms, both client and server need to |
| 188 | +negotiate a list of assertions types they can provide and will accept. The |
| 189 | +negotiation is performed at the application level prior to remote attestation |
| 190 | +and looks as follows: |
| 191 | + |
| 192 | +1. **Client** sends to the **Server** a list of |
| 193 | + [assertions](https://asylo.dev/docs/concepts/ekep.html#client_precommit-message) |
| 194 | + types it will accept |
| 195 | +1. **Server** replies with a list of |
| 196 | + [assertions](https://asylo.dev/docs/concepts/ekep.html#server_precommit-message) |
| 197 | + types it will accept |
| 198 | + |
| 199 | +Currently we are using the following assertion types: |
| 200 | + |
| 201 | +- `intel_sgx_ecdsa_0_1_report` |
| 202 | +- `amd_sev_snp_0_1_report` |
| 203 | +- `vtpm_public_key` |
| 204 | +- `eddsa_public_key` |
| 205 | + |
| 206 | +#### Assertion Generation |
| 207 | + |
| 208 | +The _Generate Assertion_ procedure in the workflow is described as follows in |
| 209 | +the case of TEE-based remote attestation: |
| 210 | + |
| 211 | +1. Derive a **Token** from the TLS session |
| 212 | + 1. **Token** is generated via deriving Exported Keying Material from an |
| 213 | + established TLS session with a specified set of parameters |
| 214 | +1. Put the **Token** into the **TEE report** request |
| 215 | + 1. This means that when TEE platform signs a **TEE report**, it also signs |
| 216 | + the provided **Token** |
| 217 | +1. Request a **TEE report** from hardware |
| 218 | +1. Firmware generates and signs a **TEE report** |
| 219 | + 1. The signed **TEE report** also gives clients information about the TEE |
| 220 | + itself (its version and etc.) and about the code that is running inside |
| 221 | + the TEE |
| 222 | +1. [_Optional_] Combine the firmware generated **TEE report** with a certificate |
| 223 | + signed by the **Provider**’s root key |
| 224 | + 1. This is required for checking the validity of **TEE reports** and TEE |
| 225 | + platform keys that were used to sign them |
| 226 | + |
| 227 | +Since Client and Server can exchange multiple assertions, each assertion should |
| 228 | +contain a **Token** that was derived using a separate Context parameter. |
| 229 | + |
| 230 | +#### Bidirectional Attestation |
| 231 | + |
| 232 | +The bidirectional workflow of the remote attestation looks as follows: |
| 233 | + |
| 234 | +1. **Client** connects to the **Server** via TLS |
| 235 | + 1. Server should guarantee _Perfect Forward Secrecy_ |
| 236 | + 1. Client checks that provided `supported_groups` for key exchange guarantee |
| 237 | + _Perfect Forward Secrecy_ |
| 238 | +1. Initial Handshake |
| 239 | + 1. Both **Client** and **Server** negotiate assertion types they can provide |
| 240 | + and will accept |
| 241 | +1. **Client** generates and sends its (possibly empty) list of assertions to the |
| 242 | + **Server** |
| 243 | +1. **Server** checks the validity of the **Client** assertions |
| 244 | + 1. It also extracts a Token from the TLS session and compares it to the Token |
| 245 | + from the **Client** assertions |
| 246 | + 1. If the **Client** assertion is not valid or the Token does not match, then |
| 247 | + the **Server** closes the connection and aborts the protocol |
| 248 | +1. **Server** generates and sends its (possibly empty) list of assertions to the |
| 249 | + **Client** |
| 250 | +1. **Client** checks the validity of the **Server** assertions |
| 251 | + 1. It also extracts a Token from the TLS session and compares it to the Token |
| 252 | + from the **Server** assertions |
| 253 | + 1. If the **Server** assertion is not valid or the Token does not match, then |
| 254 | + the **Client** closes the connection and aborts the protocol |
| 255 | +1. Secure attested channel is established |
| 256 | + |
| 257 | +<!-- From: --> |
| 258 | +<!-- https://sequencediagram.googleplex.com/view/4888181453357056 --> |
| 259 | +<img src="images/tls_attestation_workflow.png" width="850"> |
0 commit comments