/
2023-05-02-in-toto-and-slsa.md
320 lines (287 loc) · 11 KB
/
2023-05-02-in-toto-and-slsa.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
---
title: in-toto and SLSA
author: Aditya Sirish (NYU) and Tom Hennen (Google) representing the in-toto Community
is_guest_post: true
---
As an adopter of SLSA, you have likely encountered the
[in-toto project](https://in-toto.io/).
[in-toto attestations](https://github.com/in-toto/attestation) are part of
[SLSA’s recommended suite](/attestation-model#recommended-suite) for expressing
software supply chain claims. As in-toto maintainers, we’ve interacted with a
number of people who know of in-toto through SLSA but don’t fully understand the
project. For example, some were surprised to learn that "in-toto isn’t just a
format of attestations", and that the framework also defines verification
workflows that make use of attestations that are not SLSA Provenance. So, we
decided to author this post as a quick primer on in-toto, how SLSA uses in-toto,
and how other attestations can be used to complement SLSA.
## in-toto Primer
The in-toto Attestation Framework defines a fixed, lightweight "Statement" that
communicates some information about the execution of a software supply chain,
such as if the source was reviewed, or if it went through a SLSA conformant
build process. The information is communicated as a "Predicate" using a
context-specific schema identified by a "Predicate Type", and applies to one or
more software supply chain "Subjects". [SLSA Provenance](/provenance/v1) is one
such predicate type.
in-toto models the software supply chain as a series of "steps". Supply chain
owners, i.e. project owners or maintainers, define the set of actors authorized
to perform each step and rules that govern the artifacts used and produced by
the step. They can also include other arbitrary checks called "inspections" to
be performed during the verification workflow. These policies are recorded in a
piece of metadata called a supply chain "Layout", which is cryptographically
signed by the supply chain owners. As each step is performed, one or more
attestations are generated recording various aspects of the process, and during
verification, in-toto applies the policies in the layout against the set of
attestations produced during the execution of the supply chain.
## What SLSA gets from in-toto?
SLSA v1 is focused on the build aspects of the software supply chain. It defines
the Provenance predicate to record the build characteristics of the produced
artifacts. The specification describes how to verify Provenance as well as lays
out other requirements that are to be verified separately. The SLSA community
has also indicated a
[future source track](/blog/2023/04/the-breadth-and-depth-of-slsa) focused on
the security posture of how source is stored and developed prior to being fed
into a build process.
This is where _other_ in-toto predicate types can complement SLSA. in-toto
allows for defining use case specific predicates that contain contextual
information. Apart from SLSA Provenance, the framework currently
[lists definitions](https://github.com/in-toto/attestation/tree/main/spec/predicates)
for in-toto Links, results of runtime traces, Software Bill of Materials (SBOM)
specifications such as SPDX and CycloneDX, the Software Supply Chain Attribute
Integrity (SCAI) specification, and SLSA Verification Summary Attestations.
in-toto also has a process for members of the community to propose new predicate
types. Proposals are reviewed by the maintainers of the project who are supply
chain security stakeholders at Google, Verizon, Intel, Kusari, and TestifySec.
This ensures that predicate types are of high quality, useful to different
organizations and their specific use cases, and, most importantly, consistent so
that attestations are usable beyond organization boundaries.
With the
[upcoming enhancements to in-toto layouts](https://github.com/in-toto/ITE/pull/38),
supply chain owners can define granular policies for all of the different
predicates they generate during the execution of their software supply chain.
For example, they can embed SLSA Provenance specific checks alongside others
that verify best practices such as two party code reviews, successful test runs,
and so on were adhered to. Taken together, a
[bundle of in-toto attestations](https://github.com/in-toto/attestation/blob/main/spec/v1/bundle.md)
and a layout can be used to comprehensively verify a software supply chain’s
security posture.
## End-to-end attestations for your software supply chain
Let’s take a look at how other in-toto attestations can complement SLSA
Provenance. Here are a series of attestations (truncated where necessary) for
the execution of a supply chain. For the sake of this example, the attestations
are presented without their outer signing layer; in the real world, they'd all
be signed by the actors performing the corresponding operations.
### Check out the source code
First, the source repository is checked out and its Git commit is recorded using
an in-toto link.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "foo",
"digest": {
"gitCommit": "abcdef123456"
}
}],
"predicateType": "https://in-toto.io/attestation/link/v0.3",
"predicate": {
"name": "checkout",
"command": "git clone https://git.example.com/foo.git",
"materials": {},
"byproducts": {},
"environment": {}
}
}
```
### Is the code reviewed?
The attestation bundle includes a code review for the commit that was checked
out.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "foo",
"digest": {
"gitCommit": "abcdef123456"
}
}],
"predicateType": "https://in-toto.io/attestation/human-review/v0.1",
"predicate": {
"result": "PASSED",
"reviewLink": "https://cr.example.com/foo/abcdef123456",
"timestamp": "2023-04-02T12:34:23Z"
}
}
```
### Run tests
Prior to actually executing the build, the source's tests are run. This test run
and its results are recorded as a standalone attestation.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "foo",
"digest": {
"gitCommit": "abcdef123456"
}
}],
"predicateType": "https://in-toto.io/attestation/test-result/v0.1",
"predicate": {
"result": "PASSED",
"configuration": [{
"name": "foo/test.yml",
"digest": {
"gitBlob": "123456abcd"
}
}],
"url": "https://ci.example.com/23048",
"passedTests": ["(test.yml, ubuntu-latest)", "(test.yml, windows-latest)"],
"warnedTests": [],
"failedTests": []
}
}
```
### Build the final product
The build service performs the actual build itself and records SLSA Provenance
of the resulting artifact.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "bin/foo-v1.1",
"digest": {
"sha256": "ff332109abdd"
}
}],
"predicateType": "https://slsa.dev/provenance/v1",
"predicate": {
"buildDefinition": {
"buildType": "<buildType>",
"externalParameters": {
"repository": "https://git.example.com/foo.git",
"ref": "refs/heads/main"
},
"resolvedDependencies": [{
"name": "foo",
"uri": "git+https://git.example.com/foo@refs/heads/main",
"digest": {
"gitCommit": "abcdef123456"
}
}],
},
"runDetails": {
"builder": {
"id": "https://ci.example.com/",
},
}
}
}
```
### Runtime trace results of the build
In addition to recording provenance, the bundle includes the results of a
runtime trace of the build process.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "bin/foo-v1.1",
"digest": {
"sha256": "ff332109abdd"
}
}],
"predicateType": "https://in-toto.io/attestation/runtime-trace/v0.1",
"predicate": {
"monitor": {
"type": "https://github.com/cilium/tetragon/v0.8.4",
"tracePolicy": {
"policies": [{
"name": "connect",
"config": ""
}]
}
},
"monitoredProcess": {
"hostID": "https://ci.example.com",
"type": "custom",
"event": "https://ci.example.com/23055"
},
"monitorLog": {
"process": [],
"network": [],
"fileAccess": [{
"name": "foo/Makefile",
"digest": {
"sha256": "1209abcd56"
}
}, ...]
}
}
}
```
### Build compiler configuration attributes
Finally, the bundle has a Software Supply Chain Attribute Integrity (SCAI)
attestation that records some attributes of the build tool. Specifically, the
attestation indicates the build step used GCC with stack protection enabled.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "bin/foo-v1.1",
"digest": { "sha256": "ff332109abdd" }
}],
"predicateType": "https://in-toto.io/attestation/scai/attribute-report/v0.2",
"predicate": {
"attributes": [{
"attribute": "WITH_STACK_PROTECTION",
"conditions": { "flags": "-fstack-protector*" },
}],
"producer": {
"uri": "file:///usr/bin/gcc",
"name": "gcc9.3.0",
"digest": {
"sha256": "78ab6a8..."
}
}
}
}
```
### Verification
This set of metadata can be submitted to in-toto's verification workflow using a
layout conforming to the new, under-development schema. Successful verification
would result in a Verification Summary Attestation.
```json
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [{
"name": "foo-v1.1",
"digest": {
"sha256": "ff332109abdd"
}
}],
"predicateType": "https://slsa.dev/verification_summary/v1",
"predicate": {
"verifier": {
"id": "https://example.com/publication_verifier"
},
"timeVerified": "2023-04-12T23:20:50.52Z",
"resourceUri": "https://download.example.com/foo-v1.1",
"policy": {
"uri": "https://example.com/foo.layout",
"digest": {"sha256": "dabc8907fa"}
},
"inputAttestations": [{
"uri": "https://example.com/foo-v1.1.intoto.jsonl",
"digest": {"sha256": "7843adcf34"}
}],
"verificationResult": "PASSED",
"verifiedLevels": ["SLSA_LEVEL_3"],
"slsaVersion": "1.0"
}
}
```
## Get Involved
There are a number of exciting developments underway in in-toto such as the new
layouts, several new predicate specifications, and improvements to our tooling.
Come say hello at an
[in-toto community meeting](https://hackmd.io/@lukpueh/ry_e70Qqw) and on
[#in-toto](https://cloud-native.slack.com/archives/CM46K2VT2) on the
[CNCF Slack workspace](https://slack.cncf.io/).