Skip to content

Commit

Permalink
Fix verify DSSE bundles (after signing) (#258)
Browse files Browse the repository at this point in the history
* Fixes #257

When signing, if you optionally supply a trusted root we will attempt to
verify the bundle before we return it.

Previously we were using the wrong artifact digest for DSSE signing. We
could add a way to specify the artifact referred to in DSSE, but we are
already trusting the certificate identity in the user-supplied id token.

---------

Signed-off-by: Zach Steindler <[email protected]>
  • Loading branch information
steiza authored Aug 6, 2024
1 parent 6f7e99d commit 004c425
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/sign/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ func Bundle(content Content, keypair Keypair, opts BundleOptions) (*protobundle.
return nil, err
}

artifactOpts := verify.WithArtifact(bytes.NewReader(content.PreAuthEncoding()))
// Generally, you should provide an artifact when verifying.
//
// However, we just signed the DSSE object trusting the user has
// referenced the artifact(s) they intended.
artifactOpts := verify.WithoutArtifactUnsafe()
if bundle.GetMessageSignature() != nil {
artifactOpts = verify.WithArtifact(bytes.NewReader(content.PreAuthEncoding()))
}

policy := verify.NewPolicy(artifactOpts, verify.WithoutIdentitiesUnsafe())
_, err = sev.Verify(protobundle, policy)
if err != nil {
Expand Down

0 comments on commit 004c425

Please sign in to comment.