Skip to content

Commit 208ac12

Browse files
feat: vsa support (#777)
Fixes #542 Adds support for VSAs. ## Testing process - added some unit an end-to-end tests - manually invoking ``` go run ./cli/slsa-verifier/ verify-vsa \ --subject-digest gce_image_id:8970095005306000053 \ --attestation-path ./cli/slsa-verifier/testdata/vsa/gce/v1/gke-gce-pre.bcid-vsa.jsonl \ --verifier-id https://bcid.corp.google.com/verifier/bcid_package_enforcer/v0.1 \ --resource-uri gce_image://gke-node-images:gke-12615-gke1418000-cos-101-17162-463-29-c-cgpv1-pre \ --verified-level BCID_L1 \ --verified-level SLSA_BUILD_LEVEL_2 \ --public-key-path ./cli/slsa-verifier/testdata/vsa/gce/v1/vsa_signing_public_key.pem \ --public-key-id keystore://76574:prod:vsa_signing_public_key \ --print-attestation {"_type":"https://in-toto.io/Statement/v1","predicateType":"https://slsa.dev/verification_summary/v1","predicate":{"timeVerified":"2024-06-12T07:24:34.351608Z","verifier":{"id":"https://bcid.corp.google.com/verifier/bcid_package_enforcer/v0.1"},"verificationResult":"PASSED","verifiedLevels":["BCID_L1","SLSA_BUILD_LEVEL_2"],"resourceUri":"gce_image://gke-node-images:gke-12615-gke1418000-cos-101-17162-463-29-c-cgpv1-pre","policy":{"uri":"googlefile:/google_src/files/642513192/depot/google3/production/security/bcid/software/gce_image/gke/vm_images.sw_policy.textproto"}},"subject":[{"name":"_","digest":{"gce_image_id":"8970095005306000053"}}]} Verifying VSA: PASSED PASSED: SLSA verification passed ``` TODOS: - open issue on the in_toto attestations repo about the incorrect json [fields](https://github.com/in-toto/attestation/blob/36c11295429a997d5bb520b4e80a1d0c16845f9c/go/predicates/vsa/v1/vsa.pb.go#L26-L40) for vsa 1.0 --------- Signed-off-by: Ramon Petgrave <[email protected]>
1 parent 1049da4 commit 208ac12

File tree

17 files changed

+1492
-85
lines changed

17 files changed

+1492
-85
lines changed

README.md

+66
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
- [Verification for Google Cloud Build](#verification-for-google-cloud-build)
3838
- [Artifacts](#artifacts-1)
3939
- [Containers](#containers-1)
40+
- [Verification Summary Attestations (VSA)](#verification-summary-attestations-vsa)
41+
- [Caveats](#caveats)
42+
- [Sigstore](#sigstore)
43+
- [Subject Resource Descriptors](#subject-resource-descriptors)
4044
- [Known Issues](#known-issues)
4145
- [tuf: invalid key](#tuf-invalid-key)
4246
- [panic: assignment to entry in nil map](#panic-assignment-to-entry-in-nil-map)
@@ -481,6 +485,68 @@ The verified in-toto statement may be written to stdout with the
481485

482486
Note that `--source-uri` supports GitHub repository URIs like `github.com/$OWNER/$REPO` when the build was enabled with a Cloud Build [GitHub trigger](https://cloud.google.com/build/docs/automating-builds/github/build-repos-from-github). Otherwise, the build provenance will contain the name of the Cloud Storage bucket used to host the source files, usually of the form `gs://[PROJECT_ID]_cloudbuild/source` (see [Running build](https://cloud.google.com/build/docs/running-builds/submit-build-via-cli-api#running_builds)). We recommend using GitHub triggers in order to preserve the source provenance and valiate that the source came from an expected, version-controlled repository. You _may_ match on the fully-qualified tar like `gs://[PROJECT_ID]_cloudbuild/source/1665165360.279777-955d1904741e4bbeb3461080299e929a.tgz`.
483487

488+
## Verification Summary Attestations (VSA)
489+
490+
We have support for [verifying](https://slsa.dev/spec/v1.1/verification_summary#how-to-verify) VSAs.
491+
Rather than passing in filepaths as arguments, we allow passing in mulitple `--subject-digest` cli options, to
492+
accomodate subjects that are not simple-files.
493+
494+
495+
The verify-vsa command
496+
497+
```shell
498+
$ slsa-verifier verify-vsa --help
499+
Verifies SLSA VSAs for the given subject-digests
500+
501+
Usage:
502+
slsa-verifier verify-vsa [flags] subject-digest [subject-digest...]
503+
504+
Flags:
505+
--attestation-path string path to a file containing the attestation
506+
-h, --help help for verify-vsa
507+
--print-attestation [optional] print the contents of attestation to stdout
508+
--public-key-id string [optional] the ID of the public key, defaults to the SHA256 digest of the base64-encoded public key
509+
--public-key-path string path to a public key file
510+
--resource-uri string the resource URI to be verified
511+
--subject-digest stringArray the digests to be verified. Pass multiple digests by repeating the flag. e.g. --subject-digest <digest type>:<digest value> --subject-digest <digest type>:<digest value>
512+
--verified-level stringArray [optional] the levels of verification to be performed. Pass multiple digests by repeating the flag, e.g., --verified-level SLSA_BUILD_LEVEL_2 --verified-level FEDRAMP_LOW'
513+
--verifier-id string the unique verifier ID who created the attestation
514+
```
515+
516+
To verify VSAs, invoke like this
517+
518+
```shell
519+
$ slsa-verifier verify-vsa \
520+
--subject-digest gce_image_id:8970095005306000053 \
521+
--attestation-path ./cli/slsa-verifier/testdata/vsa/gce/v1/gke-gce-pre.bcid-vsa.jsonl \
522+
--verifier-id https://bcid.corp.google.com/verifier/bcid_package_enforcer/v0.1 \
523+
--resource-uri gce_image://gke-node-images:gke-12615-gke1418000-cos-101-17162-463-29-c-cgpv1-pre \
524+
--verified-level BCID_L1 \
525+
--verified-level SLSA_BUILD_LEVEL_2 \
526+
--public-key-path ./cli/slsa-verifier/testdata/vsa/gce/v1/vsa_signing_public_key.pem \
527+
--public-key-id keystore://76574:prod:vsa_signing_public_key \
528+
--print-attestation
529+
```
530+
531+
For multiple subjects, use:
532+
533+
```
534+
--subject-digest sha256:abc123
535+
--subject-digest sha256:xyz456
536+
```
537+
538+
### Caveats
539+
540+
#### Sigstore
541+
542+
This support does not work yet with VSAs wrapped in Sigstore bundles, only with simple DSSE envelopes.
543+
With that, we allow the user to pass in the public key.
544+
Note that if the DSSE Envelope `signatures` specifies a `keyid` that is not a unpadded base64 encoded sha256 hash the key, like `sha256:abc123...` (not a well-known identifier, e.g, `my-kms:prod-vsa-key`), then you must supply the `--public-key-id` cli option.
545+
546+
#### Subject Resource Descriptors
547+
548+
According to slsa.dev's [VSA schema](https://slsa.dev/spec/v1.1/verification_summary#schema), we only support the Subject's `Name` and `Digest`, not the full in_toto [Statement](https://pkg.go.dev/github.com/in-toto/attestation/go/v1#Statement)'s [ResourceDescriptor](https://github.com/in-toto/attestation/blob/main/spec/v1/resource_descriptor.md).
549+
484550
## Known Issues
485551

486552
### tuf: invalid key

cli/slsa-verifier/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ For more information on SLSA, visit https://slsa.dev`,
3737
c.AddCommand(verifyArtifactCmd())
3838
c.AddCommand(verifyImageCmd())
3939
c.AddCommand(verifyNpmPackageCmd())
40+
c.AddCommand(verifyVSACmd())
4041
// We print our own errors and usage in the check function.
4142
c.SilenceErrors = true
4243
return c

0 commit comments

Comments
 (0)